/** * sets the layer list for the spinner * * @param layers the layer list */ public void setLayerList(List<?> layers) { if (layers == null || layers.isEmpty()) { List<String> def = new ArrayList<String>(); def.add("empty"); layer.setList(def); setEnabled(false); } else { layer.setList(layers); setEnabled(true); } }
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; }
@Override protected JSpinner createSpinner(int b) { JSpinner spinner = new JSpinner(); SpinnerListModel model = new SpinnerListModel(_keyList); spinner.setModel(model); ((JSpinner.ListEditor) spinner.getEditor()).getTextField().setEditable(false); model.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { update(); } }); Dimension d = new Dimension(40, spinner.getPreferredSize().height); spinner.setMinimumSize(d); spinner.setPreferredSize(d); return spinner; }
@Override public void setAIChoices(String[] value) { java.util.List<String> choiceList = new ArrayList<String>(); for (String v : value) { choiceList.add(v); } aiModel.setList(choiceList); if (value.length > 0) { aiChoices.setValue(value[0]); } }
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 SatelliteMultiViewerCorner() { layer = new SpinnerListModel(); layer.addChangeListener( new ChangeListener() { @SuppressWarnings("rawtypes") @Override public void stateChanged(ChangeEvent e) { // find viewer for satellite if (layer.getValue() instanceof LayerViewer) setViewer((LayerViewer) layer.getValue()); else setViewer(null); } }); spinner = new JSpinner(layer); // Workaround to fix the satellite jumping issue // caused by changeevent-setviewer-dolayout-setvalue-(layoutinvalid) spinner.setPreferredSize(new Dimension(105, 22)); getSatellite().getContentPane().add(spinner, BorderLayout.NORTH); // by default disabled setEnabled(false); }
public Object getPropertyValue() { GregorianCalendar result = new GregorianCalendar(); result.setTimeZone(timezone); result.set(Calendar.YEAR, year.getNumber().intValue()); int mi = 0; String ms = month.getValue().toString(); for (int i = 0; i < MONTH_STRINGS.length; i++) { if (MONTH_STRINGS[i].equals(ms)) { mi = i; break; } } result.set(Calendar.MONTH, mi); result.set(Calendar.DATE, day.getNumber().intValue()); result.set(Calendar.HOUR_OF_DAY, hour.getNumber().intValue()); result.set(Calendar.MINUTE, min.getNumber().intValue()); result.set(Calendar.SECOND, sec.getNumber().intValue()); return result; }
public void actionPerformed(ActionEvent evt) { name = (String) text.getValue(); }
public void actionPerformed(ActionEvent evt) { pc = (String) modelA.getValue(); turns = spin.getNumber().intValue(); }