List of usage examples for javax.swing JSpinner setValue
public void setValue(Object value)
editor
. 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 { // Create a number spinner JSpinner spinner = new JSpinner(); // Set its value spinner.setValue(new Integer(100)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Create a number spinner JSpinner spinner = new JSpinner(); // Set its value spinner.setValue(new Integer(100)); System.out.println(spinner.getValue()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JSpinner spinner = new JSpinner(); spinner.addChangeListener(new SpinnerListener()); spinner.setValue(new Integer(100)); }
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 { JSpinner spinner = new JSpinner(); // Disable keyboard edits in the spinner JFormattedTextField tf = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField(); tf.setEditable(false);/*from w w w .j a v a 2s. c o m*/ tf.setBackground(Color.white); // The value of the spinner can still be programmatically changed spinner.setValue(new Integer(100)); }
From source file:coreferenceresolver.gui.MarkupGUI.java
private JScrollPane newMarkupPanel(NounPhrase np, ReviewElement reviewElement) { //MODEL// ww w. j a v a 2 s . co m Element element = new Element(); //Newly added ScrollablePanel markupPanel = new ScrollablePanel(); markupPanel.setLayout(new BoxLayout(markupPanel, BoxLayout.X_AXIS)); markupPanel.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); JTextArea npContentTxtArea = new JTextArea(); npContentTxtArea.setEditable(false); npContentTxtArea.setText(((MarkupNounPhrase) np).content); markupPanel.add(npContentTxtArea); //REF SpinnerModel refSpinnerModel = new SpinnerNumberModel(np.getChainId(), -1, COLORS.length - 1, 1); JSpinner refSpinner = new JSpinner(refSpinnerModel); refSpinner.setValue(np.getChainId()); refSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { np.setChainId((int) refSpinner.getValue()); try { rePaint(reviewElements.get(np.getReviewId()), np); } catch (BadLocationException ex) { Logger.getLogger(MarkupGUI.class.getName()).log(Level.SEVERE, null, ex); } } }); element.refSpinner = refSpinner; //TYPE String[] typeValues = { "Object", "Other", "Candidate", "Attribute" }; SpinnerModel typeSpinnerModel = new SpinnerListModel(typeValues); JSpinner typeSpinner = new JSpinner(typeSpinnerModel); typeSpinner.setValue(typeValues[np.getType()]); element.typeSpinner = typeSpinner; //REF + TYPE ScrollablePanel spinners = new ScrollablePanel(); spinners.setLayout(new BoxLayout(spinners, BoxLayout.X_AXIS)); spinners.setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT); spinners.add(refSpinner); spinners.add(typeSpinner); markupPanel.add(spinners); reviewElement.addElement(element); JScrollPane scrollMarkupPanel = new JScrollPane(markupPanel); return scrollMarkupPanel; }
From source file:es.emergya.ui.plugins.forms.FormGeneric.java
protected void addDate(Date fecha, String title, boolean editable) { rows++;// w w w . j av a2 s .c om // TODO editable mid.add(new JLabel(i18n.getString(title), JLabel.RIGHT)); JPanel panel = new JPanel(); panel.setOpaque(false); JCalendarCombo calendar = new JCalendarCombo(); calendar.setName(title); calendar.setEditable(editable); calendar.setPreferredSize(new Dimension(300, 30)); calendar.setDate(fecha); panel.add(calendar); componentes.add(calendar); JSpinner res = new JSpinner(new SpinnerDateModel()); res.setName(title); res.setPreferredSize(new Dimension(60, 30)); res.setName(title); JSpinner.DateEditor startEditor = new JSpinner.DateEditor(res, "HH:mm:ss"); startEditor.setEnabled(editable); res.setEditor(startEditor); if (fecha != null) res.setValue(fecha); componentes.add(res); panel.add(res); mid.add(panel); for (int i = 3; i < cols; i++) mid.add(Box.createHorizontalGlue()); }
From source file:es.emergya.ui.gis.popups.GenericDialog.java
protected void addDate(Date fecha, String title, boolean editable) { rows++;/*from w ww .j a v a 2 s. co m*/ // TODO editable mid.add(new JLabel(i18n.getString(title), JLabel.RIGHT)); JPanel panel = new JPanel(); panel.setOpaque(false); JCalendarCombo calendar = new JCalendarCombo(); calendar.setEditable(editable); calendar.setPreferredSize(new Dimension(300, 30)); calendar.setDate(fecha); calendar.setName(title); componentes.add(calendar); panel.add(calendar); JSpinner res = new JSpinner(new SpinnerDateModel()); res.setName(title); res.setPreferredSize(new Dimension(60, 30)); JSpinner.DateEditor startEditor = new JSpinner.DateEditor(res, "HH:mm:ss"); startEditor.setEnabled(editable); res.setEditor(startEditor); componentes.add(res); if (fecha != null) res.setValue(fecha); panel.add(res); mid.add(panel); for (int i = 3; i < cols; i++) mid.add(Box.createHorizontalGlue()); }
From source file:Forms.FrmPrincipal.java
private void genCapasOcultas() { pnlCapas.removeAll();/*w w w. j a v a2s . co m*/ int n = Integer.parseInt(spIntermedias.getValue().toString()) + 2; for (int i = 0; i < n; i++) { JSpinner spinner = new JSpinner(); spinner.setName("capa" + String.valueOf(i)); spinner.setValue(100); spinner.setSize(70, 20); spinner.setVisible(false); spinner.setVisible(true); pnlCapas.add(spinner); if (i == 0) { spinner.setValue(matrizPatrones[0].length - 1); spinner.setEnabled(false); } else if (i == n - 1) { spinner.setValue(String.valueOf(matrizPatrones[0][matrizPatrones[0].length - 1]).length()); spinner.setEnabled(false); } } pnlCapas.setVisible(false); pnlCapas.setVisible(true); }