import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Point; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JSpinner; import javax.swing.SpinnerDateModel; import javax.swing.SpinnerListModel; import javax.swing.SpinnerNumberModel; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public class SpinnerSample extends JFrame { public SpinnerSample() { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(new Dimension(500, 500)); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(new Point((d.width - this.getWidth()) / 2, (d.height - this.getHeight()) / 2)); GridBagLayout layout = new GridBagLayout(); GridBagConstraints cons = new GridBagConstraints(); this.setLayout(layout); cons.insets = new Insets(5, 5, 5, 5); cons.gridx = 0; cons.gridy = 0; cons.anchor = GridBagConstraints.WEST; cons.fill = GridBagConstraints.HORIZONTAL; JSpinner spinner = null; spinner = new JSpinner(new SpinnerDateModel()); //spinner.setEditor(new JSpinner.DateEditor(spinner, "yyyy/MM/dd HH:mm")); this.add(spinner); layout.setConstraints(spinner, cons); cons.gridy++; spinner = new JSpinner(new SpinnerListModel(new String[] { "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日" })); this.add(spinner); layout.setConstraints(spinner, cons); cons.gridy++; spinner = new JSpinner(new SpinnerNumberModel()); this.add(spinner); layout.setConstraints(spinner, cons); this.setVisible(true); this.pack(); } public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } new SpinnerSample(); } }