Java 类javax.swing.JSpinner.NumberEditor 实例源码

项目:esadb    文件:TableEditor.java   
public TableEditor(JComponent component, int version) {
    super();

    if (component instanceof JSpinner) {
        JSpinner spinner = (JSpinner) component;

        switch (version) {
            case 0:
                spinner.setModel(new SpinnerNumberModel(new Integer(1900), new Integer(0), null, new Integer(1)));
                spinner.setEditor(new NumberEditor(spinner, "0000"));
                break;
            case 1:
                spinner.setModel(new SpinnerNumberModel(new Double(0), new Double(0), null, new Double(0.01)));
                spinner.setEditor(new NumberEditor(spinner, "0.000"));
                break;
        }
    }

    this.component = component;
}
项目:cn1    文件:JSpinnerTest.java   
public void testNumberEditor_NumberEditor() {
    spinner.getModel().setValue(new Integer(5));
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    assertTrue(numEditor.getTextField().isEditable());
    assertTrue(numEditor.getTextField().getFormatter() instanceof NumberFormatter);
    assertEquals(numEditor.getTextField().getValue(), new Integer(5));
    assertSame(((NumberFormatter) numEditor.getTextField().getFormatter()).getValueClass(),
            Integer.class);
    assertNull(((NumberFormatter) numEditor.getTextField().getFormatter()).getMinimum());
    assertNull(((NumberFormatter) numEditor.getTextField().getFormatter()).getMaximum());
    assertTrue(numEditor.getFormat().equals(new DecimalFormat()));
    spinner.setModel(abstractModel);
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            new JSpinner.NumberEditor(spinner);
        }
    });
}
项目:cn1    文件:JSpinnerTest.java   
public void testNumberEditor_formatter() {
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    final Integer max1 = new Integer(777);
    NumberFormatter numberFormatter = ((NumberFormatter) numEditor.getTextField()
            .getFormatter());
    numberFormatter.setMaximum(max1);
    assertSame(numberFormatter.getMaximum(), max1);
    assertSame(numEditor.getModel().getMaximum(), max1);
    final Integer max2 = new Integer(555);
    numEditor.getModel().setMaximum(max2);
    assertSame(numberFormatter.getMaximum(), max2);
    assertSame(numEditor.getModel().getMaximum(), max2);
    SpinnerNumberModel old = (SpinnerNumberModel) spinner.getModel();
    spinner.setModel(abstractModel);
    final Integer max3 = new Integer(333);
    old.setMaximum(max3);
    assertSame(((NumberFormatter) ((NumberEditor) spinner.getEditor()).getTextField()
            .getFormatter()).getMaximum(), max3);
}
项目:freeVM    文件:JSpinnerTest.java   
public void testNumberEditor_NumberEditor() {
    spinner.getModel().setValue(new Integer(5));
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    assertTrue(numEditor.getTextField().isEditable());
    assertTrue(numEditor.getTextField().getFormatter() instanceof NumberFormatter);
    assertEquals(numEditor.getTextField().getValue(), new Integer(5));
    assertSame(((NumberFormatter) numEditor.getTextField().getFormatter()).getValueClass(),
            Integer.class);
    assertNull(((NumberFormatter) numEditor.getTextField().getFormatter()).getMinimum());
    assertNull(((NumberFormatter) numEditor.getTextField().getFormatter()).getMaximum());
    assertTrue(numEditor.getFormat().equals(new DecimalFormat()));
    spinner.setModel(abstractModel);
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            new JSpinner.NumberEditor(spinner);
        }
    });
}
项目:freeVM    文件:JSpinnerTest.java   
public void testNumberEditor_formatter() {
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    final Integer max1 = new Integer(777);
    NumberFormatter numberFormatter = ((NumberFormatter) numEditor.getTextField()
            .getFormatter());
    numberFormatter.setMaximum(max1);
    assertSame(numberFormatter.getMaximum(), max1);
    assertSame(numEditor.getModel().getMaximum(), max1);
    final Integer max2 = new Integer(555);
    numEditor.getModel().setMaximum(max2);
    assertSame(numberFormatter.getMaximum(), max2);
    assertSame(numEditor.getModel().getMaximum(), max2);
    SpinnerNumberModel old = (SpinnerNumberModel) spinner.getModel();
    spinner.setModel(abstractModel);
    final Integer max3 = new Integer(333);
    old.setMaximum(max3);
    assertSame(((NumberFormatter) ((NumberEditor) spinner.getEditor()).getTextField()
            .getFormatter()).getMaximum(), max3);
}
项目:freeVM    文件:JSpinnerTest.java   
public void testNumberEditor_NumberEditor() {
    spinner.getModel().setValue(new Integer(5));
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    assertTrue(numEditor.getTextField().isEditable());
    assertTrue(numEditor.getTextField().getFormatter() instanceof NumberFormatter);
    assertEquals(numEditor.getTextField().getValue(), new Integer(5));
    assertSame(((NumberFormatter) numEditor.getTextField().getFormatter()).getValueClass(),
            Integer.class);
    assertNull(((NumberFormatter) numEditor.getTextField().getFormatter()).getMinimum());
    assertNull(((NumberFormatter) numEditor.getTextField().getFormatter()).getMaximum());
    assertTrue(numEditor.getFormat().equals(new DecimalFormat()));
    spinner.setModel(abstractModel);
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            new JSpinner.NumberEditor(spinner);
        }
    });
}
项目:freeVM    文件:JSpinnerTest.java   
public void testNumberEditor_formatter() {
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    final Integer max1 = new Integer(777);
    NumberFormatter numberFormatter = ((NumberFormatter) numEditor.getTextField()
            .getFormatter());
    numberFormatter.setMaximum(max1);
    assertSame(numberFormatter.getMaximum(), max1);
    assertSame(numEditor.getModel().getMaximum(), max1);
    final Integer max2 = new Integer(555);
    numEditor.getModel().setMaximum(max2);
    assertSame(numberFormatter.getMaximum(), max2);
    assertSame(numEditor.getModel().getMaximum(), max2);
    SpinnerNumberModel old = (SpinnerNumberModel) spinner.getModel();
    spinner.setModel(abstractModel);
    final Integer max3 = new Integer(333);
    old.setMaximum(max3);
    assertSame(((NumberFormatter) ((NumberEditor) spinner.getEditor()).getTextField()
            .getFormatter()).getMaximum(), max3);
}
项目:JavaGraph    文件:LTSDisplay.java   
/**
 * Refreshes the background colour, based on the question whether the LTS is
 * filtered or incompletely displayed.
 */
public void refreshBackground() {
    Color background =
        getJGraph().isComplete() ? JAttr.STATE_BACKGROUND : JAttr.FILTER_BACKGROUND;
    getGraphPanel().setEnabledBackground(background);
    ((NumberEditor) getBoundSpinner().getEditor()).getTextField()
        .setBackground(isEnabled() ? background : null);
}
项目:AutoAnnotateApp    文件:SwingUtil.java   
@SuppressWarnings("serial")
public static void makeSmall(final JComponent... components) {
    if (components == null || components.length == 0)
        return;

    for (JComponent c : components) {
        if (LookAndFeelUtil.isAquaLAF()) {
            c.putClientProperty("JComponent.sizeVariant", "small");
        } else {
            if (c.getFont() != null)
                c.setFont(c.getFont().deriveFont(LookAndFeelUtil.getSmallFontSize()));
        }

        if (c instanceof JList) {
            ((JList<?>) c).setCellRenderer(new DefaultListCellRenderer() {
                @Override
                public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                        boolean isSelected, boolean cellHasFocus) {
                    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                    setFont(getFont().deriveFont(LookAndFeelUtil.getSmallFontSize()));

                    return this;
                }
            });
        }
        if(c instanceof JSpinner) {
            JSpinner spinner = (JSpinner) c;
            JComponent comp = spinner.getEditor();
            if(comp instanceof NumberEditor) {
                NumberEditor numberEditor = (NumberEditor) comp;
                makeSmall(numberEditor.getTextField());
            }
        }
    }
}
项目:swingx    文件:SpinningCalendarHeaderHandler.java   
/**
 * Creates and returns the JSpinner used for year navigation.
 * 
 * @return
 */
private JSpinner createSpinner() {
    JSpinner spinner = new JSpinner();
    spinner.setFocusable(false);
    spinner.setBorder(BorderFactory.createEmptyBorder());
    NumberEditor editor = new NumberEditor(spinner);
    editor.getFormat().setGroupingUsed(false);
    editor.getTextField().setFocusable(false);
    spinner.setEditor(editor);
    return spinner;
}
项目:platypus-js    文件:ModelSpin.java   
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    if (decorated.getEditor() instanceof NumberEditor) {
        JFormattedTextField ftf = ((NumberEditor) decorated.getEditor()).getTextField();
        ftf.getActionMap().remove(TextFieldsCommitAction.COMMIT_ACTION_NAME);
        ftf.getActionMap().put(TextFieldsCommitAction.COMMIT_ACTION_NAME, new TextFieldsCommitAction(ftf));
    }
    EventQueue.invokeLater(() -> {
        decorated.requestFocus();
    });
    return super.getTableCellEditorComponent(table, value, isSelected, row, column); //To change body of generated methods, choose Tools | Templates.
}
项目:platypus-js    文件:ModelSpin.java   
@Override
public boolean stopCellEditing() {
    if (decorated.getEditor() instanceof NumberEditor) {
        JFormattedTextField ftf = ((NumberEditor) decorated.getEditor()).getTextField();
        try {
            ftf.commitEdit();
        } catch (ParseException ex) {
            Logger.getLogger(ModelDate.class.getName()).log(Level.WARNING, null, ex);
        }
    }
    return super.stopCellEditing();
}
项目:svarog    文件:MonitorConfigPanel.java   
protected IntegerSpinner getOpenbciPortSpinner() {
    if (openbciPortSpinner == null) {
        openbciPortSpinner = new IntegerSpinner(new SpinnerNumberModel(1, 1, 99999, 1));
        NumberEditor editor = (NumberEditor) openbciPortSpinner.getEditor();
        editor.getFormat().setGroupingUsed(false);
    }
    return openbciPortSpinner;
}
项目:cn1    文件:JSpinnerTest.java   
public void testSetGetEditor() throws Exception {
    JComponent oldEditor = spinner.getEditor();
    assertNotNull(oldEditor);
    JComponent editor = new JProgressBar();
    spinner.setEditor(editor);
    assertFalse(Arrays.asList(spinner.getChangeListeners()).contains(editor));
    assertTrue(propertyChangeController.isChanged(StringConstants.EDITOR_PROPERTY_CHANGED));
    assertSame(editor, spinner.getEditor());
    editor = new JSpinner.NumberEditor(spinner);
    spinner.setEditor(editor);
    assertTrue(Arrays.asList(spinner.getChangeListeners()).contains(editor));
    assertTrue(propertyChangeController.isChanged(StringConstants.EDITOR_PROPERTY_CHANGED));
    assertSame(editor, spinner.getEditor());
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            spinner.setEditor(null);
        }
    });
    spinner = new JSpinner();
    spinner.setEditor(oldEditor);
    assertFalse(Arrays.asList(spinner.getChangeListeners()).contains(oldEditor));
    spinner = new JSpinner();
    oldEditor = spinner.getEditor();
    spinner.setEditor(oldEditor);
    spinner.setModel(new SpinnerDateModel());
    assertNotSame(spinner.getEditor(), oldEditor);
    spinner = new JSpinner();
    oldEditor = spinner.getEditor();
    spinner.setEditor(oldEditor);
    spinner.setModel(new SpinnerDateModel());
    assertNotSame(spinner.getEditor(), oldEditor);
}
项目:cn1    文件:JSpinnerTest.java   
public void testCreateEditor() {
    SpinnerModel model = new SpinnerNumberModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.NumberEditor);
    model = new SpinnerDateModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.DateEditor);
    model = new SpinnerListModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.ListEditor);
    assertTrue(spinner.createEditor(abstractModel) instanceof JSpinner.DefaultEditor);
}
项目:cn1    文件:JSpinnerTest.java   
public void testNumberEditor_getModel() {
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    assertSame(numEditor.getModel(), spinner.getModel());
    spinner.setModel(abstractModel);
    testExceptionalCase(new ExceptionalCase(null, ClassCastException.class) {
        @Override
        public void exceptionalAction() throws Exception {
            ((NumberEditor) spinner.getEditor()).getModel();
        }
    });
}
项目:GC4S    文件:DoubleRangeSpinnerInputPanel.java   
protected void configureTextField(JSpinner spinner) {
    JSpinner.NumberEditor editor = 
        new JSpinner.NumberEditor(spinner, "0.0#####");
    JFormattedTextField textField = editor.getTextField();
    textField.setColumns(5);
    spinner.setEditor(editor);
}
项目:GC4S    文件:DoubleRangeSpinnerInputPanel.java   
private void setRangeTextFieldColor(boolean validValues) {
    Color backgroundColor = getTextFieldBackgroundColor(validValues);
    ((JSpinner.NumberEditor) this.rangeStartSpinner.getEditor())
        .getTextField().setBackground(backgroundColor);
    ((JSpinner.NumberEditor) this.rangeEndSpinner.getEditor())
        .getTextField().setBackground(backgroundColor);
}
项目:GC4S    文件:DoubleRangeSpinnerInputPanel.java   
protected static double getSpinnerValue(JSpinner spinner) {
    NumberEditor editor = ((JSpinner.NumberEditor) spinner.getEditor());
    try {
        return editor.getFormat().parse(
                editor.getTextField().getText()
            ).doubleValue();
    } catch (ParseException e) {
        return 0d;
    }
}
项目:polydes    文件:IntType.java   
public SpinnerIntegerEditor(EditorProperties props, PropertiesSheetStyle style)
{
    int step = or(props.get(STEP), 1);

    model = new SpinnerNumberModel(0, 0, 0, step);
    spinner = new OutlinelessSpinner(model);
    field = ((NumberEditor) spinner.getEditor()).getTextField();
    spinner.setBorder
    (
        BorderFactory.createCompoundBorder
        (
            BorderFactory.createLineBorder(style.fieldBorder != null ? style.fieldBorder : style.fieldBg, 1),
            BorderFactory.createLineBorder(style.fieldBg, 2)
        )
    );
    field.setBackground(style.fieldBg);
    field.setForeground(style.fieldtextColor);
    spinner.addChangeListener(new ChangeListener()
    {
        @Override
        public void stateChanged(ChangeEvent e)
        {
            if(VerificationHelper.isInteger(field.getText()))
                updated();
        }
    });
}
项目:polydes    文件:FloatType.java   
public SpinnerFloatEditor(EditorProperties props, PropertiesSheetStyle style)
{
    float step = or(props.<Float>get(STEP), .01f);

    model = new SpinnerNumberModel(0f, 0f, 0f, step);
    spinner = new OutlinelessSpinner(model);
    field = ((NumberEditor) spinner.getEditor()).getTextField();
    spinner.setBorder
    (
        BorderFactory.createCompoundBorder
        (
            BorderFactory.createLineBorder(style.fieldBorder != null ? style.fieldBorder : style.fieldBg, 1),
            BorderFactory.createLineBorder(style.fieldBg, 2)
        )
    );
    field.setBackground(style.fieldBg);
    field.setForeground(style.fieldtextColor);
    spinner.addChangeListener(new ChangeListener()
    {
        @Override
        public void stateChanged(ChangeEvent e)
        {
            if(VerificationHelper.isFloat(field.getText()))
                updated();
        }
    });
}
项目:freeVM    文件:JSpinnerTest.java   
public void testSetGetEditor() throws Exception {
    JComponent oldEditor = spinner.getEditor();
    assertNotNull(oldEditor);
    JComponent editor = new JProgressBar();
    spinner.setEditor(editor);
    assertFalse(Arrays.asList(spinner.getChangeListeners()).contains(editor));
    assertTrue(propertyChangeController.isChanged(StringConstants.EDITOR_PROPERTY_CHANGED));
    assertSame(editor, spinner.getEditor());
    editor = new JSpinner.NumberEditor(spinner);
    spinner.setEditor(editor);
    assertTrue(Arrays.asList(spinner.getChangeListeners()).contains(editor));
    assertTrue(propertyChangeController.isChanged(StringConstants.EDITOR_PROPERTY_CHANGED));
    assertSame(editor, spinner.getEditor());
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            spinner.setEditor(null);
        }
    });
    spinner = new JSpinner();
    spinner.setEditor(oldEditor);
    assertFalse(Arrays.asList(spinner.getChangeListeners()).contains(oldEditor));
    spinner = new JSpinner();
    oldEditor = spinner.getEditor();
    spinner.setEditor(oldEditor);
    spinner.setModel(new SpinnerDateModel());
    assertNotSame(spinner.getEditor(), oldEditor);
    spinner = new JSpinner();
    oldEditor = spinner.getEditor();
    spinner.setEditor(oldEditor);
    spinner.setModel(new SpinnerDateModel());
    assertNotSame(spinner.getEditor(), oldEditor);
}
项目:freeVM    文件:JSpinnerTest.java   
public void testCreateEditor() {
    SpinnerModel model = new SpinnerNumberModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.NumberEditor);
    model = new SpinnerDateModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.DateEditor);
    model = new SpinnerListModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.ListEditor);
    assertTrue(spinner.createEditor(abstractModel) instanceof JSpinner.DefaultEditor);
}
项目:freeVM    文件:JSpinnerTest.java   
public void testNumberEditor_getModel() {
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    assertSame(numEditor.getModel(), spinner.getModel());
    spinner.setModel(abstractModel);
    testExceptionalCase(new ExceptionalCase(null, ClassCastException.class) {
        @Override
        public void exceptionalAction() throws Exception {
            ((NumberEditor) spinner.getEditor()).getModel();
        }
    });
}
项目:freeVM    文件:JSpinnerTest.java   
public void testSetGetEditor() throws Exception {
    JComponent oldEditor = spinner.getEditor();
    assertNotNull(oldEditor);
    JComponent editor = new JProgressBar();
    spinner.setEditor(editor);
    assertFalse(Arrays.asList(spinner.getChangeListeners()).contains(editor));
    assertTrue(propertyChangeController.isChanged(StringConstants.EDITOR_PROPERTY_CHANGED));
    assertSame(editor, spinner.getEditor());
    editor = new JSpinner.NumberEditor(spinner);
    spinner.setEditor(editor);
    assertTrue(Arrays.asList(spinner.getChangeListeners()).contains(editor));
    assertTrue(propertyChangeController.isChanged(StringConstants.EDITOR_PROPERTY_CHANGED));
    assertSame(editor, spinner.getEditor());
    testExceptionalCase(new IllegalArgumentCase() {
        @Override
        public void exceptionalAction() throws Exception {
            spinner.setEditor(null);
        }
    });
    spinner = new JSpinner();
    spinner.setEditor(oldEditor);
    assertFalse(Arrays.asList(spinner.getChangeListeners()).contains(oldEditor));
    spinner = new JSpinner();
    oldEditor = spinner.getEditor();
    spinner.setEditor(oldEditor);
    spinner.setModel(new SpinnerDateModel());
    assertNotSame(spinner.getEditor(), oldEditor);
    spinner = new JSpinner();
    oldEditor = spinner.getEditor();
    spinner.setEditor(oldEditor);
    spinner.setModel(new SpinnerDateModel());
    assertNotSame(spinner.getEditor(), oldEditor);
}
项目:freeVM    文件:JSpinnerTest.java   
public void testCreateEditor() {
    SpinnerModel model = new SpinnerNumberModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.NumberEditor);
    model = new SpinnerDateModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.DateEditor);
    model = new SpinnerListModel();
    spinner.setModel(model);
    assertTrue(spinner.createEditor(model) instanceof JSpinner.ListEditor);
    assertTrue(spinner.createEditor(abstractModel) instanceof JSpinner.DefaultEditor);
}
项目:freeVM    文件:JSpinnerTest.java   
public void testNumberEditor_getModel() {
    NumberEditor numEditor = new NumberEditor(spinner);
    spinner.setEditor(numEditor);
    assertSame(numEditor.getModel(), spinner.getModel());
    spinner.setModel(abstractModel);
    testExceptionalCase(new ExceptionalCase(null, ClassCastException.class) {
        @Override
        public void exceptionalAction() throws Exception {
            ((NumberEditor) spinner.getEditor()).getModel();
        }
    });
}
项目:WorldPainter    文件:BrushOptions.java   
/**
 * Creates new form BrushOptions
 */
public BrushOptions() {
    initComponents();

    // Eliminate thousands separators to make spinners smaller:
    spinnerAbove.setEditor(new NumberEditor(spinnerAbove, "0"));
    spinnerBelow.setEditor(new NumberEditor(spinnerBelow, "0"));
}
项目:WorldPainter    文件:AddLayerDialog.java   
/**
 * Creates new form AddLayerDialog
 */
public AddLayerDialog(Window parent, List<Layer> allLayers) {
    super(parent);
    this.allLayers = allLayers;

    initComponents();

    spinnerFactor.setEditor(new NumberEditor(spinnerFactor, "0"));

    rootPane.setDefaultButton(buttonOK);
    pack();
    setLocationRelativeTo(parent);
}
项目:PhET    文件:TestHTMLNodeBounds.java   
public TestHTMLNodeBounds() {
    super( TestHTMLNodeBounds.class.getName() );
    setSize( new Dimension( 800, 450 ) );

    // Piccolo canvas
    PSwingCanvas canvas = new PSwingCanvas();
    canvas.removeInputEventListener( canvas.getZoomEventHandler() );
    canvas.removeInputEventListener( canvas.getPanEventHandler() );

    // the HTMLNode
    String html = "<html><center>How many<br>reactants<br>in this reaction?</center></html>";
    htmlNode = new HTMLNode( html );
    htmlNode.setFont( new PhetFont( DEFAULT_FONT_SIZE ) );
    htmlNode.addPropertyChangeListener( new PropertyChangeListener() {
        // when the bounds change, update boundsNode
        public void propertyChange( PropertyChangeEvent event ) {
            if ( event.getPropertyName().equals( PNode.PROPERTY_FULL_BOUNDS ) ) {
                updateBoundsNode();
            }
        }
    } );
    canvas.getLayer().addChild( htmlNode );

    // displays the bounds of htmlNode
    boundsNode = new PPath( htmlNode.getBounds() );
    boundsNode.setStroke( new BasicStroke( 1f ) );
    boundsNode.setStrokePaint( Color.RED );
    canvas.getLayer().addChild( boundsNode );

    // label to show font name
    JLabel fontNameLabel = new JLabel( "font face name: " + new PhetFont().getFontName() );

    // spinner to change the font size of htmlNode
    final JSpinner fontSizeSpinner = new JSpinner();
    fontSizeSpinner.setModel( new SpinnerNumberModel( DEFAULT_FONT_SIZE, MIN_FONT_SIZE, MAX_FONT_SIZE, 1 ) );
    NumberEditor editor = new NumberEditor( fontSizeSpinner );
    // don't allow editing of the textfield, so we don't have to handle bogus input
    editor.getTextField().setEditable( false );
    fontSizeSpinner.setEditor( editor );
    fontSizeSpinner.addChangeListener( new ChangeListener() {
        // when the spinner changes, update htmlNode font
        public void stateChanged( ChangeEvent e ) {
            int fontSize = ( (Integer) fontSizeSpinner.getValue() ).intValue();
            htmlNode.setFont( new PhetFont( fontSize ) );
        }
    } );

    JPanel controlPanel = new JPanel();
    controlPanel.add( fontNameLabel );
    controlPanel.add( Box.createHorizontalStrut( 40 ) );
    controlPanel.add( new JLabel( "font size:" ) );
    controlPanel.add( fontSizeSpinner );

    JPanel mainPanel = new JPanel( new BorderLayout() );
    mainPanel.add( canvas, BorderLayout.CENTER );
    mainPanel.add( controlPanel, BorderLayout.SOUTH );

    setContentPane( mainPanel );
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public NumberEditor getByteEditor() {
    return this.byteEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public NumberEditor getDoubleEditor() {
    return this.doubleEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public NumberEditor getFloatEditor() {
    return this.floatEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public NumberEditor getIntEditor() {
    return this.intEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public NumberEditor getShortEditor() {
    return this.shortEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public void setByteEditor(final NumberEditor byteEditor) {
    this.byteEditor = byteEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public void setDoubleEditor(final NumberEditor doubleEditor) {
    this.doubleEditor = doubleEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public void setFloatEditor(final NumberEditor floatEditor) {
    this.floatEditor = floatEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public void setIntEditor(final NumberEditor intEditor) {
    this.intEditor = intEditor;
}
项目:AppWoksUtils    文件:ExtSpinnerColumn.java   
public void setLongEditor(final NumberEditor longEditor) {
    this.longEditor = longEditor;
}