本文整理汇总了Java中javax.swing.JSpinner.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java JSpinner.setFont方法的具体用法?Java JSpinner.setFont怎么用?Java JSpinner.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JSpinner
的用法示例。
在下文中一共展示了JSpinner.setFont方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initComponents
import javax.swing.JSpinner; //导入方法依赖的package包/类
private void initComponents() {
this.setLayout(new BorderLayout());
epochs = new JSpinner(new SpinnerNumberModel(10, 10, 50, 1));
JPanel epochOption = new JPanel(new BorderLayout());
JPanel flowTemp = new JPanel(new FlowLayout(FlowLayout.LEFT));
epochs.setPreferredSize(new Dimension(70, 40));
epochs.setFont(new Font(epochs.getFont().getName(), epochs.getFont().getStyle(), epochs.getFont().getSize() + 4));
flowTemp.add(new JLabel("<html><body><h3>Select the maximum number of epochs: </h3></body></html> "));
flowTemp.add(epochs);
JButton setEpoch = new JButton(this.setEpoch);
setEpoch.setPreferredSize(new Dimension(85, 35));
flowTemp.add(setEpoch);
epochOption.add(flowTemp, BorderLayout.CENTER);
//JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
//btnPanel.add(setEpoch);
//epochOption.add(btnPanel,BorderLayout.SOUTH);
this.add(epochOption, BorderLayout.NORTH);
}
示例2: init
import javax.swing.JSpinner; //导入方法依赖的package包/类
private void init() {
spinnerModel = new SpinnerNumberModel(0, 0, 500, 1);
spinner = new JSpinner(spinnerModel);
spinner.setFont(new java.awt.Font("",0,15));
gbLayout = new GridBagLayout();
gbConst = new GridBagConstraints();
panel = new JPanel();
setLabel("");
panel.setLayout(gbLayout);
setMinimum(0);
setMaximum(500);
spinner.addChangeListener(new SpinnerListener());
gbConst.gridx = 0; gbConst.gridy = 0;
gbLayout.setConstraints(spinner, gbConst);
panel.add(spinner);
}
示例3: initComponents
import javax.swing.JSpinner; //导入方法依赖的package包/类
private void initComponents() {
this.setLayout(new BorderLayout());
epochs = new JSpinner(new SpinnerNumberModel(10, 10, 50, 1));
JPanel epochOption = new JPanel(new BorderLayout());
JPanel flowTemp = new JPanel(new FlowLayout(FlowLayout.LEFT));
epochs.setPreferredSize(new Dimension(70, 40));
epochs.setFont(new Font(epochs.getFont().getName(), epochs.getFont().getStyle(), epochs.getFont().getSize() + 4));
flowTemp.add(new JLabel("<html><body><h3>Select the maximum number of epochs: </h3></body></html> "));
flowTemp.add(epochs);
JButton setEpoch = new JButton(this.setEpoch);
setEpoch.setPreferredSize(new Dimension(85, 35));
flowTemp.add(setEpoch);
epochOption.add(flowTemp, BorderLayout.CENTER);
this.add(epochOption, BorderLayout.NORTH);
}
示例4: testDefaultFont
import javax.swing.JSpinner; //导入方法依赖的package包/类
private static void testDefaultFont(final JFrame frame) {
final JSpinner spinner = new JSpinner();
final JSpinner spinner_u = new JSpinner();
frame.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 50));
frame.getContentPane().add(spinner);
frame.getContentPane().add(spinner_u);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
final DefaultEditor ed = (DefaultEditor) spinner.getEditor();
final DefaultEditor ed_u = (DefaultEditor) spinner_u.getEditor();
ed_u.getTextField().setFont(USERS_FONT);
for (int i = 5; i < 40; i += 5) {
/*
* Validate that the font of the text field is changed to the
* font of JSpinner if the font of text field was not set by the
* user.
*/
final Font tff = ed.getTextField().getFont();
if (!(tff instanceof UIResource)) {
throw new RuntimeException("Font must be UIResource");
}
if (spinner.getFont().getSize() != tff.getSize()) {
throw new RuntimeException("Rrong size");
}
spinner.setFont(new Font("dialog", Font.BOLD, i));
/*
* Validate that the font of the text field is NOT changed to the
* font of JSpinner if the font of text field was set by the user.
*/
final Font tff_u = ed_u.getTextField().getFont();
if (tff_u instanceof UIResource || !tff_u.equals(USERS_FONT)) {
throw new RuntimeException("Font must NOT be UIResource");
}
if (spinner_u.getFont().getSize() == tff_u.getSize()) {
throw new RuntimeException("Wrong size");
}
spinner_u.setFont(new Font("dialog", Font.BOLD, i));
}
}