Example usage for javax.swing JSpinner.NumberEditor addFocusListener

List of usage examples for javax.swing JSpinner.NumberEditor addFocusListener

Introduction

In this page you can find the example usage for javax.swing JSpinner.NumberEditor addFocusListener.

Prototype

public synchronized void addFocusListener(FocusListener l) 

Source Link

Document

Adds the specified focus listener to receive focus events from this component when this component gains input focus.

Usage

From source file:org.jcurl.demo.tactics.BroomPromptSwingBean.java

public BroomPromptSwingBean() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    final Box b = Box.createVerticalBox();
    {/*from   w  w w.  ja v  a  2  s.c o m*/
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Active"));
        tb.add(rock = new JComboBox(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 }));
        rock.setPrototypeDisplayValue(8);
        rock.addItemListener(this);
        dark = new JRadioButton("dark");
        dark.addActionListener(this);
        light = new JRadioButton("light");
        light.addActionListener(this);
        final ButtonGroup bg = new ButtonGroup();
        bg.add(dark);
        bg.add(light);
        tb.add(dark);
        tb.add(light);
        b.add(tb);
    }
    {
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Handle"));
        in = new JRadioButton("In Turn");
        in.addActionListener(this);
        out = new JRadioButton("Out Turn");
        out.addActionListener(this);
        final ButtonGroup bg = new ButtonGroup();
        bg.add(in);
        bg.add(out);
        tb.add(out);
        tb.add(in);
        tb.add(Box.createHorizontalGlue());
        b.add(tb);
    }
    {
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Split Time"));

        if (UseJSpinnerBoundedRange) {
            split2 = new JSpinnerBoundedRange();
            split2.addFocusListener(this);
            split = null;
        } else {
            split2 = null;
            split = new JSpinner();
            // log.info(split.getEditor().getClass().getName());
            split.addFocusListener(this);
            final JSpinner.NumberEditor ed = (JSpinner.NumberEditor) split.getEditor();
            ed.addFocusListener(this);
            ed.getTextField().addFocusListener(this);
        }

        tb.add(split2);

        tb.add(dt = new JComboBox(new Object[] { "1/1000 sec", "1/100 sec", "1/10 sec", "sec" }));
        tb.add(Box.createHorizontalGlue());
        b.add(tb);
        dt.setEnabled(false);
    }
    {
        final JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.setBorder(BorderFactory.createTitledBorder("Broom Position"));
        {
            x = new JSpinnerNumberUnit();
            x.setLabel("x: ");
            x.setBase(Unit.METER);
            x.setChoose(Unit.FOOT, Unit.INCH, Unit.CENTIMETER, Unit.METER);
            x.setModel(new SpinnerNumberModel(0.0, -IceSize.SIDE_2_CENTER, IceSize.SIDE_2_CENTER, 0.1));
            x.addChangeListener(this);
            x.addPropertyChangeListener(this);
            p.add(x);
        }
        {
            y = new JSpinnerNumberUnit();
            y.setLabel("y: ");
            y.setBase(Unit.METER);
            y.setChoose(Unit.FOOT, Unit.INCH, Unit.CENTIMETER, Unit.METER);
            y.setModel(new SpinnerNumberModel(0.0, -IceSize.BACK_2_TEE, IceSize.HOG_2_TEE, 0.1));
            y.addChangeListener(this);
            y.addPropertyChangeListener(this);
            p.add(y);
        }
        b.add(p);
    }
    this.add(b);
}