Package javax.swing.JSpinner

Examples of javax.swing.JSpinner.DefaultEditor


    SlidingSpinner(ColorPanel panel, JComponent label) {
        this.panel = panel;
        this.label = label;
        this.slider.addChangeListener(this);
        this.spinner.addChangeListener(this);
        DefaultEditor editor = (DefaultEditor) this.spinner.getEditor();
        ValueFormatter.init(3, false, editor.getTextField());
        editor.setFocusable(false);
        this.spinner.setFocusable(false);
    }
View Full Code Here


    public void testGetAccessibleContext() {
    }

    public void testDefaultEditor_DefaultEditor() {
        DefaultEditor defaultEditor = (DefaultEditor) spinner.createEditor(abstractModel);
        spinner.setEditor(defaultEditor);
        assertTrue(Arrays.asList(defaultEditor.getTextField().getPropertyChangeListeners())
                .contains(defaultEditor));
        assertFalse(defaultEditor.getTextField().isEditable());
        assertSame(defaultEditor.getTextField(), defaultEditor.getComponent(0));
        JFormattedTextField textField = ((DefaultEditor) spinner.getEditor()).getTextField();
        assertSame(textField.getActionForKeyStroke(KeyStroke.getKeyStroke("DOWN")), textField
                .getActionForKeyStroke(KeyStroke.getKeyStroke("UP")));
        textField.setFormatterFactory(new DefaultFormatterFactory(null));
        textField.setValue("TEST");
View Full Code Here

        textField.setValue("TEST");
        assertEquals(new Integer(0), textField.getValue());
    }

    public void testDefaultEditor_propertyChange() throws Exception {
        DefaultEditor defaultEditor = (DefaultEditor) spinner.getEditor();
        PropertyChangeController pcc = new PropertyChangeController();
        ChangeController modelController = new ChangeController();
        defaultEditor.getTextField().addPropertyChangeListener(pcc);
        spinner.getModel().addChangeListener(modelController);
        defaultEditor.getTextField().setText("15");
        defaultEditor.commitEdit();
        assertTrue(pcc.isChanged());
        assertTrue(modelController.isChanged());
        modelController.reset();
        defaultEditor.getTextField().removePropertyChangeListener(defaultEditor);
        defaultEditor.getTextField().setText("18");
        defaultEditor.commitEdit();
        defaultEditor.getTextField().addPropertyChangeListener(defaultEditor);
        defaultEditor.propertyChange(new PropertyChangeEvent(defaultEditor.getTextField(),
                "value", defaultEditor.getTextField().getValue(), new Integer(10)));
        assertTrue(modelController.isChanged());
        modelController.reset();
        defaultEditor.getTextField().removePropertyChangeListener(defaultEditor);
        defaultEditor.getTextField().setText("58");
        defaultEditor.commitEdit();
        defaultEditor.getTextField().addPropertyChangeListener(defaultEditor);
        defaultEditor.propertyChange(new PropertyChangeEvent(new Integer(10), "value",
                new Integer(13), new Integer(10)));
        assertFalse(modelController.isChanged());
    }
View Full Code Here

                new Integer(13), new Integer(10)));
        assertFalse(modelController.isChanged());
    }

    public void testDefaultEditor_stateChange() {
        DefaultEditor defaultEditor = (DefaultEditor) spinner.getEditor();
        PropertyChangeController pcc = new PropertyChangeController();
        defaultEditor.getTextField().addPropertyChangeListener(pcc);
        spinner.setValue(new Integer(159));
        assertTrue(pcc.isChanged());
    }
View Full Code Here

        spinner.setValue(new Integer(159));
        assertTrue(pcc.isChanged());
    }

    public void testDefaultEditor_LayoutSizes() {
        DefaultEditor defaultEditor = (DefaultEditor) spinner.createEditor(abstractModel);
        spinner.setEditor(defaultEditor);
        assertEquals(defaultEditor.minimumLayoutSize(spinner), Utilities.addInsets(
                defaultEditor.getTextField().getMinimumSize(), spinner.getInsets()));
        assertEquals(defaultEditor.preferredLayoutSize(spinner), Utilities.addInsets(
                defaultEditor.getTextField().getPreferredSize(), spinner.getInsets()));
    }
View Full Code Here

            }
        }
    }

    private void addSpinnerEventHandler() {
        DefaultEditor editor = (DefaultEditor) timeSpinner.getEditor();
        editor.getTextField().addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(MouseEvent e) {
                enableAutoGo(false);
            }
View Full Code Here

    SlidingSpinner(ColorPanel panel, JComponent label) {
        this.panel = panel;
        this.label = label;
        this.slider.addChangeListener(this);
        this.spinner.addChangeListener(this);
        DefaultEditor editor = (DefaultEditor) this.spinner.getEditor();
        ValueFormatter.init(3, false, editor.getTextField());
        editor.setFocusable(false);
        this.spinner.setFocusable(false);
    }
View Full Code Here

                new Integer(13), new Integer(10)));
        assertFalse(modelController.isChanged());
    }

    public void testDefaultEditor_stateChange() {
        DefaultEditor defaultEditor = (DefaultEditor) spinner.getEditor();
        PropertyChangeController pcc = new PropertyChangeController();
        defaultEditor.getTextField().addPropertyChangeListener(pcc);
        spinner.setValue(new Integer(159));
        assertTrue(pcc.isChanged());
    }
View Full Code Here

        spinner.setValue(new Integer(159));
        assertTrue(pcc.isChanged());
    }

    public void testDefaultEditor_LayoutSizes() {
        DefaultEditor defaultEditor = (DefaultEditor) spinner.createEditor(abstractModel);
        spinner.setEditor(defaultEditor);
        assertEquals(defaultEditor.minimumLayoutSize(spinner), Utilities.addInsets(
                defaultEditor.getTextField().getMinimumSize(), spinner.getInsets()));
        assertEquals(defaultEditor.preferredLayoutSize(spinner), Utilities.addInsets(
                defaultEditor.getTextField().getPreferredSize(), spinner.getInsets()));
    }
View Full Code Here

    public void testGetAccessibleContext() {
    }

    public void testDefaultEditor_DefaultEditor() {
        DefaultEditor defaultEditor = (DefaultEditor) spinner.createEditor(abstractModel);
        spinner.setEditor(defaultEditor);
        assertTrue(Arrays.asList(defaultEditor.getTextField().getPropertyChangeListeners())
                .contains(defaultEditor));
        assertFalse(defaultEditor.getTextField().isEditable());
        assertSame(defaultEditor.getTextField(), defaultEditor.getComponent(0));
        JFormattedTextField textField = ((DefaultEditor) spinner.getEditor()).getTextField();
        assertSame(textField.getActionForKeyStroke(KeyStroke.getKeyStroke("DOWN")), textField
                .getActionForKeyStroke(KeyStroke.getKeyStroke("UP")));
        textField.setFormatterFactory(new DefaultFormatterFactory(null));
        textField.setValue("TEST");
View Full Code Here

TOP

Related Classes of javax.swing.JSpinner.DefaultEditor

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.