List of usage examples for javax.swing SpinnerNumberModel SpinnerNumberModel
public SpinnerNumberModel(double value, double minimum, double maximum, double stepSize)
SpinnerNumberModel
with the specified value
, minimum
/maximum
bounds, and stepSize
. From source file:Main.java
public static void main(String args[]) { SpinnerNumberModel model = new SpinnerNumberModel(0.0, -1000.0, 1000.0, 0.1); JSpinner s = new JSpinner(model); JSpinner.NumberEditor editor = new JSpinner.NumberEditor(s); s.setEditor(editor);//from w w w .jav a2 s.c o m JTextField stepText = new JTextField(10); JButton bStepSet = new JButton("Set Step"); bStepSet.addActionListener(e -> { Double val = Double.parseDouble(stepText.getText().trim()); model.setStepSize(val); }); JFrame f = new JFrame(); Container c = f.getContentPane(); c.add(s); JPanel southPanel = new JPanel(); southPanel.add(stepText); southPanel.add(bStepSet); c.add(southPanel, BorderLayout.SOUTH); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Create a number spinner that only handles values in the range [0,100] int min = 0;//from w w w .j av a 2s . c om int max = 100; int step = 5; int initValue = 50; SpinnerModel model = new SpinnerNumberModel(initValue, min, max, step); JSpinner spinner = new JSpinner(model); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25); JSpinner spinner = new JSpinner(model); JComponent editor = new JSpinner.NumberEditor(spinner, "#,##0.###"); spinner.setEditor(editor);//from w w w .jav a 2 s . c om JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(spinner, BorderLayout.CENTER); frame.add(panel1, BorderLayout.SOUTH); frame.setSize(200, 90); frame.setVisible(true); }
From source file:SpinnerNumberEditorSample1.java
public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25); JSpinner spinner = new JSpinner(model); JComponent editor = new JSpinner.NumberEditor(spinner); spinner.setEditor(editor);//from w ww . j av a 2 s. com JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(spinner, BorderLayout.CENTER); frame.add(panel1, BorderLayout.SOUTH); frame.setSize(200, 90); frame.setVisible(true); }
From source file:SpinnerNumberEditorSample2.java
public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25); JSpinner spinner = new JSpinner(model); JComponent editor = new JSpinner.NumberEditor(spinner, "#,##0.###"); spinner.setEditor(editor);//from w w w . j a va 2s . c om JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(spinner, BorderLayout.CENTER); frame.add(panel1, BorderLayout.SOUTH); frame.setSize(200, 90); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame("Spinning"); Container contentPane = frame.getContentPane(); String months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; SpinnerModel model = new SpinnerListModel(months); JSpinner spinner = new JSpinner(model); contentPane.add(spinner, BorderLayout.NORTH); SpinnerDateModel model2 = new SpinnerDateModel(); model2.setCalendarField(Calendar.WEEK_OF_MONTH); JSpinner spinner2 = new JSpinner(model2); JSpinner.DateEditor editor2 = new JSpinner.DateEditor(spinner2, "MMMMM dd, yyyy"); spinner2.setEditor(editor2);//from w w w. j ava 2 s . c o m frame.getContentPane().add(spinner2, BorderLayout.CENTER); SpinnerNumberModel model3 = new SpinnerNumberModel(50, 0, 100, 5); JSpinner spinner3 = new JSpinner(model3); frame.getContentPane().add(spinner3, BorderLayout.SOUTH); frame.setSize(200, 100); frame.setVisible(true); }
From source file:SpinnerTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Spinning"); Container contentPane = frame.getContentPane(); String months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; SpinnerModel model = new SpinnerListModel(months); JSpinner spinner = new JSpinner(model); contentPane.add(spinner, BorderLayout.NORTH); SpinnerDateModel model2 = new SpinnerDateModel(); model2.setCalendarField(Calendar.WEEK_OF_MONTH); JSpinner spinner2 = new JSpinner(model2); JSpinner.DateEditor editor2 = new JSpinner.DateEditor(spinner2, "MMMMM dd, yyyy"); spinner2.setEditor(editor2);//from ww w. ja v a 2 s. c o m frame.getContentPane().add(spinner2, BorderLayout.CENTER); SpinnerNumberModel model3 = new SpinnerNumberModel(50, 0, 100, 5); JSpinner spinner3 = new JSpinner(model3); frame.getContentPane().add(spinner3, BorderLayout.SOUTH); frame.setSize(200, 100); frame.show(); }
From source file:Main.java
public Main() { JSpinner m_numberSpinner;//from w w w . j a v a 2s. co m SpinnerNumberModel m_numberSpinnerModel; Double current = new Double(5.50); Double min = new Double(0.00); Double max = new Double(10.00); Double step = new Double(0.25); m_numberSpinnerModel = new SpinnerNumberModel(current, min, max, step); m_numberSpinner = new JSpinner(m_numberSpinnerModel); add(m_numberSpinner); }
From source file:Main.java
public Main() { MyCanvas thingy = new MyCanvas(); setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.add(thingy);/* w w w . j a va 2s . c o 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); }
From source file:estacionmeteorologica.main.java
/** * Creates new form main/*from ww w .j a va 2 s . c o m*/ */ public main() { initComponents(); SpinnerNumberModel modelodia = new SpinnerNumberModel(1, 1, 30, 1); jSpinnerdia.setModel(modelodia); getRootPane().setDefaultButton(jButtonincluir); }