List of usage examples for javax.swing JSpinner JSpinner
public JSpinner(SpinnerModel model)
From source file:Main.java
public static void main(String[] argv) throws Exception { SpinnerListModel listModel = new SpinnerListModel(new String[] { "red", "green", "blue" }); JSpinner spinner = new JSpinner(listModel); spinner.setValue("blue"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { SpinnerDateModel dateModel = new SpinnerDateModel(); JSpinner spinner = new JSpinner(dateModel); Calendar calendar = new GregorianCalendar(2000, Calendar.JANUARY, 1); spinner.setValue(calendar.getTime()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { SpinnerCircularListModel listModel = new SpinnerCircularListModel(new String[] { "red", "green", "blue" }); JSpinner spinner = new JSpinner(listModel); }
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 a 2 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 ww .j a v a 2 s.c o m 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:SpinnerDemo.java
public static void main(String[] args) { JFrame jf = new JFrame("It Spins"); Container cp = jf.getContentPane(); cp.setLayout(new GridLayout(0, 1)); // Create a JSpinner using one of the pre-defined SpinnerModels JSpinner dates = new JSpinner(new SpinnerDateModel()); cp.add(dates);/*from w w w . j a va 2 s . c om*/ // Create a JSPinner using a SpinnerListModel. String[] data = { "One", "Two", "Three" }; JSpinner js = new JSpinner(new SpinnerListModel(data)); cp.add(js); jf.setSize(100, 80); jf.setVisible(true); }
From source file:SpinnerDateSample.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerDateModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("Dates/Date"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.CENTER); frame.setSize(200, 90);//from w ww . java2s . c o m frame.setVisible(true); }
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);// w w w. j av a2 s .c o m 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:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerDateModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("All"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.NORTH); frame.setSize(200, 90);/*from w w w .jav a 2 s . c om*/ frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerListModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("None"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.NORTH); frame.setSize(200, 90);//w w w.j a v a 2 s . c om frame.setVisible(true); }