List of usage examples for javax.swing JSpinner JSpinner
public JSpinner(SpinnerModel model)
From source file:CyclingSpinnerListModel.java
public static void main(String[] a) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSpinner spinner = new JSpinner(new CyclingSpinnerListModel(new String[] { "A", "B", "C" })); frame.add(spinner);//from www. j a va2 s .c o m frame.setSize(300, 200); frame.setVisible(true); }
From source file:GrayModel.java
public static void main(String[] args) { JFrame frame = new JFrame("SpinnerDemo4"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent newContentPane = new Main(); newContentPane.setOpaque(true);/*from w ww . j a va 2 s .c o m*/ frame.setContentPane(newContentPane); frame.add(new JLabel("Shade of Gray:"), "North"); frame.add(new JSpinner(new GrayModel(170))); frame.pack(); frame.setVisible(true); }
From source file:GrayModel.java
public static void main(String[] args) { JFrame frame = new JFrame("SpinnerDemo4"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent newContentPane = new SpinnerDemo4(); newContentPane.setOpaque(true);/* ww w. j av a 2 s . com*/ frame.setContentPane(newContentPane); frame.add(new JLabel("Shade of Gray:"), "North"); frame.add(new JSpinner(new GrayModel(170))); frame.pack(); frame.setVisible(true); }
From source file:Main.java
private static JSpinner createSpinner(SpinnerModel model) { return new JSpinner(model); }
From source file:Main.java
private static JSpinner addLabeledSpinner(String label, SpinnerModel model, boolean b) { JLabel l = new JLabel(label); //c.add(l);//w w w . j a v a 2s .c o m JSpinner spinner = new JSpinner(model); l.setLabelFor(spinner); //c.add(spinner); return spinner; }
From source file:Main.java
public static JSpinner createSpinner(SpinnerModel model) { JSpinner result = new JSpinner(model); return result; }
From source file:Main.java
private static JSpinner makeDigitsOnlySpinnerUsingDocumentFilter() { JSpinner spinner = new JSpinner(new SpinnerNumberModel()); JSpinner.NumberEditor jsEditor = (JSpinner.NumberEditor) spinner.getEditor(); JFormattedTextField textField = jsEditor.getTextField(); DocumentFilter digitOnlyFilter = new DocumentFilter() { @Override/*from w w w. j av a 2 s . com*/ public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException { if (stringContainsOnlyDigits(string)) { super.insertString(fb, offset, string, attr); } } @Override public void remove(FilterBypass fb, int offset, int length) throws BadLocationException { super.remove(fb, offset, length); } @Override public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException { if (stringContainsOnlyDigits(text)) { super.replace(fb, offset, length, text, attrs); } } private boolean stringContainsOnlyDigits(String text) { for (int i = 0; i < text.length(); i++) { if (!Character.isDigit(text.charAt(i))) { return false; } } return true; } }; NumberFormat format = NumberFormat.getPercentInstance(); format.setGroupingUsed(false); format.setGroupingUsed(true); format.setMaximumIntegerDigits(10); format.setMaximumFractionDigits(2); format.setMinimumFractionDigits(5); textField.setFormatterFactory(new DefaultFormatterFactory(new InternationalFormatter(format) { @Override protected DocumentFilter getDocumentFilter() { return digitOnlyFilter; } })); return spinner; }
From source file:Main.java
public Main() { setSize(200, 100);// ww w . j a v a 2s . c o m setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); add(new JLabel("Expiration Date:")); Date today = new Date(); JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); add(s); setVisible(true); }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);/*from w w w.j a v a2 s .c om*/ setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); c.add(new JLabel("Expiration Date:")); Date today = new Date(); JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); }
From source file:Main.java
public Main() { super("Month Spinner"); setSize(200, 100);//from www . j ava 2 s . c o m setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = getContentPane(); c.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4)); c.add(new JLabel("Expiration Date:")); Date today = new Date(); JSpinner s = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor de = new JSpinner.DateEditor(s, "MM/yy"); s.setEditor(de); c.add(s); setVisible(true); System.out.println(s.getNextValue()); }