Java Code Examples for javax.swing.JSpinner.DefaultEditor

The following examples show how to use javax.swing.JSpinner.DefaultEditor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: pcgen   Source File: SkillInfoTab.java    License: GNU Lesser General Public License v2.1 7 votes vote down vote up
private SkillRankSpinnerEditor(SkillRankSpinnerModel model)
{
	super(model);
	this.model = model;

	DefaultEditor editor = new DefaultEditor(spinner);
	NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.#")); //$NON-NLS-1$
	formatter.setValueClass(Float.class);
	DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);

	JFormattedTextField ftf = editor.getTextField();
	ftf.setEditable(true);
	ftf.setFormatterFactory(factory);
	ftf.setHorizontalAlignment(SwingConstants.RIGHT);

	spinner.setEditor(editor);
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: ColorPanel.java    License: Apache License 2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 3
Source Project: dragonwell8_jdk   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 4
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 5
Source Project: TencentKona-8   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 6
Source Project: TencentKona-8   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 7
Source Project: jdk8u60   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 8
Source Project: jdk8u60   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 9
Source Project: JDKSourceCode1.8   Source File: ColorPanel.java    License: MIT License 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 10
Source Project: openjdk-jdk8u   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 11
Source Project: openjdk-jdk8u   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 12
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 13
Source Project: Bytecoder   Source File: ColorPanel.java    License: Apache License 2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 14
Source Project: openjdk-jdk9   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 15
Source Project: openjdk-jdk9   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) {
        return;
    }

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(new FontUIResource(spinner.getFont()));
    }

    final JFormattedTextField editorTextField = ((DefaultEditor) editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(new FontUIResource(spinner.getFont()));
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 16
Source Project: openjdk-jdk9   Source File: bug6421058.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static void testDefaultFont(final JFrame frame) {
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JSpinner spinner = new JSpinner();
    frame.add(spinner);
    frame.setSize(300, 100);
    frame.setVisible(true);

    final DefaultEditor editor = (DefaultEditor) spinner.getEditor();
    final Font editorFont = editor.getTextField().getFont();

    /*
     * 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.
     */

    if (!(editorFont instanceof UIResource)) {
        throw new RuntimeException("Font must be UIResource");
    }
    if (!editorFont.equals(spinner.getFont())) {
        throw new RuntimeException("Wrong FONT");
    }
}
 
Example 17
Source Project: jdk8u-jdk   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 18
Source Project: jdk8u-jdk   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 19
Source Project: hottub   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 20
Source Project: hottub   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 21
Source Project: openjdk-8-source   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 22
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 23
Source Project: openjdk-8   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 24
Source Project: openjdk-8   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 25
Source Project: jdk8u_jdk   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 26
Source Project: jdk8u_jdk   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}
 
Example 27
Source Project: littleluck   Source File: LuckSpinnerUI.java    License: Apache License 2.0 6 votes vote down vote up
protected JComponent createEditor()
{
    JComponent editor = super.createEditor();

    // 设置文本框属性
    // set text frame info.
    if(editor instanceof DefaultEditor)
    {
        ((DefaultEditor)editor).getTextField().setBorder(null);

        ((DefaultEditor)editor).getTextField().setOpaque(false);

        ((DefaultEditor)editor).setOpaque(false);
    }

    return editor;
}
 
Example 28
Source Project: pcgen   Source File: SkillInfoTab.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private SkillRankSpinnerEditor(SkillRankSpinnerModel model)
{
	super(model);
	this.model = model;

	DefaultEditor editor = new DefaultEditor(spinner);
	NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.#")); //$NON-NLS-1$
	formatter.setValueClass(Float.class);
	DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter);

	JFormattedTextField ftf = editor.getTextField();
	ftf.setEditable(true);
	ftf.setFormatterFactory(factory);
	ftf.setHorizontalAlignment(SwingConstants.RIGHT);

	spinner.setEditor(editor);
}
 
Example 29
Source Project: jdk8u-jdk   Source File: ColorPanel.java    License: GNU General Public License v2.0 6 votes vote down vote up
void buildPanel() {
    int count = this.model.getCount();
    this.spinners[4].setVisible(count > 4);
    for (int i = 0; i < count; i++) {
        String text = this.model.getLabel(this, i);
        Object object = this.spinners[i].getLabel();
        if (object instanceof JRadioButton) {
            JRadioButton button = (JRadioButton) object;
            button.setText(text);
            button.getAccessibleContext().setAccessibleDescription(text);
        }
        else if (object instanceof JLabel) {
            JLabel label = (JLabel) object;
            label.setText(text);
        }
        this.spinners[i].setRange(this.model.getMinimum(i), this.model.getMaximum(i));
        this.spinners[i].setValue(this.values[i]);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleName(text);
        DefaultEditor editor = (DefaultEditor) this.spinners[i].getSpinner().getEditor();
        editor.getTextField().getAccessibleContext().setAccessibleName(text);
        this.spinners[i].getSlider().getAccessibleContext().setAccessibleDescription(text);
        this.spinners[i].getSpinner().getAccessibleContext().setAccessibleDescription(text);
        editor.getTextField().getAccessibleContext().setAccessibleDescription(text);
    }
}
 
Example 30
Source Project: jdk8u-jdk   Source File: AquaSpinnerUI.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void fixupEditor(final JComponent editor) {
    if (!(editor instanceof DefaultEditor)) return;

    editor.setOpaque(false);
    editor.setInheritsPopupMenu(true);

    if (editor.getFont() instanceof UIResource) {
        editor.setFont(spinner.getFont());
    }

    final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
    if (editorTextField.getFont() instanceof UIResource) {
        editorTextField.setFont(spinner.getFont());
    }
    final InputMap spinnerInputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    final InputMap editorInputMap = editorTextField.getInputMap();
    final KeyStroke[] keys = spinnerInputMap.keys();
    for (final KeyStroke k : keys) {
        editorInputMap.put(k, spinnerInputMap.get(k));
    }
}