当前位置: 首页>>代码示例>>Java>>正文


Java NumberEditor类代码示例

本文整理汇总了Java中javax.swing.JSpinner.NumberEditor的典型用法代码示例。如果您正苦于以下问题:Java NumberEditor类的具体用法?Java NumberEditor怎么用?Java NumberEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NumberEditor类属于javax.swing.JSpinner包,在下文中一共展示了NumberEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TableEditor

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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;
}
 
开发者ID:SmallLars,项目名称:esadb,代码行数:21,代码来源:TableEditor.java

示例2: testNumberEditor_NumberEditor

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:JSpinnerTest.java

示例3: testNumberEditor_formatter

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:JSpinnerTest.java

示例4: refreshBackground

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:12,代码来源:LTSDisplay.java

示例5: makeSmall

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
@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());
            }
        }
    }
}
 
开发者ID:BaderLab,项目名称:AutoAnnotateApp,代码行数:36,代码来源:SwingUtil.java

示例6: createSpinner

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:16,代码来源:SpinningCalendarHeaderHandler.java

示例7: getTableCellEditorComponent

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
@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.
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:13,代码来源:ModelSpin.java

示例8: stopCellEditing

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
@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();
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:13,代码来源:ModelSpin.java

示例9: getOpenbciPortSpinner

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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;
}
 
开发者ID:BrainTech,项目名称:svarog,代码行数:9,代码来源:MonitorConfigPanel.java

示例10: testSetGetEditor

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:34,代码来源:JSpinnerTest.java

示例11: testCreateEditor

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:JSpinnerTest.java

示例12: testNumberEditor_getModel

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:shannah,项目名称:cn1,代码行数:13,代码来源:JSpinnerTest.java

示例13: configureTextField

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
protected void configureTextField(JSpinner spinner) {
    JSpinner.NumberEditor editor = 
        new JSpinner.NumberEditor(spinner, "0.0#####");
    JFormattedTextField textField = editor.getTextField();
    textField.setColumns(5);
    spinner.setEditor(editor);
}
 
开发者ID:sing-group,项目名称:GC4S,代码行数:8,代码来源:DoubleRangeSpinnerInputPanel.java

示例14: setRangeTextFieldColor

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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);
}
 
开发者ID:sing-group,项目名称:GC4S,代码行数:8,代码来源:DoubleRangeSpinnerInputPanel.java

示例15: getSpinnerValue

import javax.swing.JSpinner.NumberEditor; //导入依赖的package包/类
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;
    }
}
 
开发者ID:sing-group,项目名称:GC4S,代码行数:11,代码来源:DoubleRangeSpinnerInputPanel.java


注:本文中的javax.swing.JSpinner.NumberEditor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。