List of usage examples for javax.swing SpinnerNumberModel addChangeListener
public void addChangeListener(ChangeListener l)
From source file:Main.java
public Main() { MyCanvas thingy = new MyCanvas(); setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.add(thingy);/*from ww w .j a v a 2s .co m*/ JScrollPane scroll = new JScrollPane(); scroll.setViewportView(panel); add(scroll, BorderLayout.CENTER); SpinnerNumberModel spmodel = new SpinnerNumberModel(thingy.getThingySize(), 10.0, 2000.0, 10.0); spmodel.addChangeListener(e -> thingy.setThingySize((Double) spmodel.getNumber())); add(new JSpinner(spmodel), BorderLayout.NORTH); }