Package javax.swing.JSpinner

Examples of javax.swing.JSpinner.NumberEditor


            }
        });
    }

    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()
View Full Code Here


        assertSame(((NumberFormatter) ((NumberEditor) spinner.getEditor()).getTextField()
                .getFormatter()).getMaximum(), max3);
    }

    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();
View Full Code Here

         */
        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;
        }
View Full Code Here

                defaultEditor.getTextField().getPreferredSize(), spinner.getInsets()));
    }

    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);
View Full Code Here

            }
        });
    }

    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()
View Full Code Here

        assertSame(((NumberFormatter) ((NumberEditor) spinner.getEditor()).getTextField()
                .getFormatter()).getMaximum(), max3);
    }

    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();
View Full Code Here

TOP

Related Classes of javax.swing.JSpinner.NumberEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.