public DateTimePropertyInputField( final Object value, final UpdateStatus status, final Color bgColor) { setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); setBackground(bgColor); GregorianCalendar cal = (value == null ? new GregorianCalendar() : (GregorianCalendar) value); timezone = cal.getTimeZone(); day = new SpinnerNumberModel(cal.get(Calendar.DATE), 1, 31, 1); addSpinner(new JSpinner(day), status); month = new SpinnerListModel(MONTH_STRINGS); month.setValue(MONTH_STRINGS[cal.get(Calendar.MONTH)]); JSpinner monthSpinner = new JSpinner(month); JComponent editor = monthSpinner.getEditor(); if (editor instanceof JSpinner.DefaultEditor) { JFormattedTextField tf = ((JSpinner.DefaultEditor) editor).getTextField(); tf.setColumns(6); tf.setHorizontalAlignment(JTextField.RIGHT); } addSpinner(monthSpinner, status); year = new SpinnerNumberModel(cal.get(Calendar.YEAR), 0, 9999, 1); JSpinner yearSpinner = new JSpinner(year); yearSpinner.setEditor(new JSpinner.NumberEditor(yearSpinner, "#")); yearSpinner.getEditor().setBackground(bgColor); addSpinner(yearSpinner, status); add(new JLabel(" ")); hour = new SpinnerNumberModel(cal.get(Calendar.HOUR_OF_DAY), 0, 23, 1); JSpinner hourSpinner = new JSpinner(hour); addSpinner(hourSpinner, status); add(new JLabel(":")); min = new SpinnerNumberModel(cal.get(Calendar.MINUTE), 0, 59, 1); JSpinner minSpinner = new JSpinner(min); addSpinner(minSpinner, status); add(new JLabel(":")); sec = new SpinnerNumberModel(cal.get(Calendar.SECOND), 0, 59, 1); JSpinner secSpinner = new JSpinner(sec); addSpinner(secSpinner, status); add(new JLabel(" " + timezone.getDisplayName(true, TimeZone.SHORT))); }
public JMenuItem GUIEdit() { JMenu menu = new JMenu("Edit Action"); JPanel panel = new JPanel(); panel.add(new JLabel("Name:")); SpinnerListModel model = new SpinnerListModel(getQuest().getActors().getActorNames()); model.setValue(name); JSpinner spin = new JSpinner(model); ((JSpinner.DefaultEditor) spin.getEditor()).getTextField().setColumns(16); panel.add(spin); menu.add(panel); JMenuItem store = new JMenuItem("Store Edits"); store.addActionListener(new EditAction(model)); menu.add(store); return menu; }