javax.swing.JSpinner.DefaultEditor Java Examples

The following examples show how to use javax.swing.JSpinner.DefaultEditor. 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 File: SkillInfoTab.java    From pcgen with 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 File: AquaSpinnerUI.java    From openjdk-jdk8u with 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 #3
Source File: AquaSpinnerUI.java    From jdk8u60 with 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 #4
Source File: ColorPanel.java    From JDKSourceCode1.8 with 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 #5
Source File: AquaSpinnerUI.java    From jdk8u-jdk with 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 #6
Source File: ColorPanel.java    From hottub with 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 #7
Source File: OptionsEtcPanel.java    From rest-client with Apache License 2.0 6 votes vote down vote up
OptionsEtcPanel(){
    this.setLayout(new FlowLayout(FlowLayout.LEFT));
    jcb_indentResponse.setMnemonic('a');

    jcb_syntaxRequest.setToolTipText("Requires RESTClient restart!");
    jcb_syntaxResponse.setToolTipText("Requires RESTClient restart!");
    
    JPanel jp = new JPanel();
    jp.setLayout(new GridLayout(4, 1));
    
    jp.add(jcb_indentResponse);
    jp.add(jcb_syntaxRequest);
    jp.add(jcb_syntaxResponse);
    JPanel jp_scrollSpeed = new JPanel(new BorderLayout());
    JPanel jp_scrollSpeed_inner = new JPanel(new FlowLayout());
    jp_scrollSpeed_inner.add(new JLabel("Text areas scroll speed"));
    jp_scrollSpeed_inner.add(js_scrollSpeed);
    jp_scrollSpeed.add(BorderLayout.WEST, jp_scrollSpeed_inner);
    jp.add(jp_scrollSpeed);
    ((JSpinner.DefaultEditor)js_scrollSpeed.getEditor()).getTextField().setColumns(2);
    
    this.add(jp);
}
 
Example #8
Source File: ColorPanel.java    From TencentKona-8 with 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 #9
Source File: AquaSpinnerUI.java    From jdk8u-dev-jdk with 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 #10
Source File: AquaSpinnerUI.java    From dragonwell8_jdk with 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 #11
Source File: AquaSpinnerUI.java    From hottub with 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
Source File: ColorPanel.java    From dragonwell8_jdk with 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 #13
Source File: ColorPanel.java    From openjdk-8-source with 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 #14
Source File: AquaSpinnerUI.java    From TencentKona-8 with 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 #15
Source File: ColorPanel.java    From openjdk-jdk8u with 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 #16
Source File: ColorPanel.java    From jdk8u-jdk with 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 #17
Source File: ColorPanel.java    From openjdk-8 with 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 File: SkillInfoTab.java    From pcgen with 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 #19
Source File: LuckSpinnerUI.java    From littleluck with 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 #20
Source File: AquaSpinnerUI.java    From jdk8u-jdk with 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 File: ColorPanel.java    From jdk1.8-source-analysis with 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 #22
Source File: AquaSpinnerUI.java    From jdk8u_jdk with 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 #23
Source File: ColorPanel.java    From openjdk-jdk8u-backup with 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 File: ColorPanel.java    From jdk8u-jdk with 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 #25
Source File: ColorPanel.java    From jdk8u_jdk with 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 File: bug6421058.java    From openjdk-jdk9 with 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 #27
Source File: ColorPanel.java    From Bytecoder with 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 #28
Source File: ColorPanel.java    From openjdk-jdk9 with 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 #29
Source File: AquaSpinnerUI.java    From openjdk-8 with 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 #30
Source File: AquaSpinnerUI.java    From openjdk-jdk9 with 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));
    }
}