List of usage examples for javax.swing JSpinner JSpinner
public JSpinner(SpinnerModel model)
From source file:MainClass.java
public static void main(String args[]) { JFrame f = new JFrame("JSpinner Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH); String days[] = symbols.getWeekdays(); SpinnerModel model1 = new SpinnerListModel(days); SpinnerModel model2 = new SpinnerDateModel(); JSpinner spinner1 = new JSpinner(model1); JSpinner spinner2 = new JSpinner(model2); f.add(spinner1, BorderLayout.NORTH); f.add(spinner2, BorderLayout.SOUTH); f.setSize(300, 100);// w w w . j a va 2s.c o m f.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 av a2 s . c om 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:Main.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Source: " + e.getSource()); }//from w w w . j a v a2 s.c om }; SpinnerModel model3 = new SpinnerNumberModel(); JSpinner spinner3 = new JSpinner(model3); spinner3.addChangeListener(listener); ChangeListener[] changeListeners = spinner3.getChangeListeners(); frame.add(spinner3, 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); ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Source: " + e.getSource()); }//www . j av a 2 s. c o m }; SpinnerModel model3 = new SpinnerNumberModel(); JSpinner spinner3 = new JSpinner(model3); spinner3.addChangeListener(listener); frame.add(spinner3, BorderLayout.SOUTH); frame.setSize(200, 90); 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);/* ww w. jav 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 static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH); String days[] = symbols.getWeekdays(); SpinnerModel model1 = new SpinnerListModel(days); JSpinner spinner1 = new JSpinner(model1); ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Source: " + e.getSource()); }/*from ww w .ja v a 2 s. c om*/ }; spinner1.addChangeListener(listener); JLabel label1 = new JLabel("French Days/List"); 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); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] args) { JFrame frame = new JFrame(); Calendar now = Calendar.getInstance(); Calendar earliest = (Calendar) now.clone(); earliest.add(Calendar.MONTH, -6); Calendar latest = (Calendar) now.clone(); latest.add(Calendar.MONTH, 6); SpinnerModel model = new SpinnerDateModel(now.getTime(), earliest.getTime(), latest.getTime(), Calendar.WEEK_OF_YEAR); final JSpinner spinner = new JSpinner(model); model.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println(((SpinnerDateModel) e.getSource()).getDate()); }//from w w w .ja v a 2 s . co m }); frame.getContentPane().add("North", new JLabel("Choose a week")); frame.getContentPane().add("Center", spinner); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:SpinnerDateStartEndSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Calendar cal = Calendar.getInstance(); Date now = cal.getTime();//from w w w . j a v a2 s.c o m cal.add(Calendar.YEAR, -50); Date startDate = cal.getTime(); cal.add(Calendar.YEAR, 100); Date endDate = cal.getTime(); SpinnerModel model = new SpinnerDateModel(now, startDate, endDate, Calendar.YEAR); JSpinner spinner1 = new JSpinner(model); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(spinner1, 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); Calendar cal = Calendar.getInstance(); Date now = cal.getTime();/* w ww . j a va 2 s.co m*/ cal.add(Calendar.YEAR, -50); Date startDate = cal.getTime(); cal.add(Calendar.YEAR, 100); Date endDate = cal.getTime(); SpinnerModel model2 = new SpinnerDateModel(now, startDate, endDate, Calendar.YEAR); JSpinner spinner2 = new JSpinner(model2); JLabel label2 = new JLabel("Range"); JPanel panel2 = new JPanel(new BorderLayout()); panel2.add(label2, BorderLayout.WEST); panel2.add(spinner2, BorderLayout.CENTER); frame.add(panel2, BorderLayout.SOUTH); frame.setSize(200, 90); frame.setVisible(true); }
From source file:RolloverSpinnerListModel.java
public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String[] values = new String[] { "a", "b", "c" }; RolloverSpinnerListModel model = new RolloverSpinnerListModel(values); JSpinner spinner1 = new JSpinner(model); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.SOUTH); frame.setSize(200, 90);/*w w w . ja v a2 s . c om*/ frame.setVisible(true); }