Example usage for javax.swing SpinnerNumberModel getNumber

List of usage examples for javax.swing SpinnerNumberModel getNumber

Introduction

In this page you can find the example usage for javax.swing SpinnerNumberModel getNumber.

Prototype

public Number getNumber() 

Source Link

Document

Returns the value of the current element of the sequence.

Usage

From source file:Main.java

public Main() {
    MyCanvas thingy = new MyCanvas();
    setLayout(new BorderLayout());
    JPanel panel = new JPanel();
    panel.add(thingy);//from   w w  w  .j a va2  s.com
    JScrollPane scroll = new JScrollPane();
    scroll.setViewportView(panel);
    add(scroll, BorderLayout.CENTER);
    SpinnerNumberModel spmodel = new SpinnerNumberModel(thingy.getThingySize(), 10.0, 2000.0, 10.0);
    spmodel.addChangeListener(e -> thingy.setThingySize((Double) spmodel.getNumber()));
    add(new JSpinner(spmodel), BorderLayout.NORTH);
}

From source file:de.unibayreuth.bayeos.goat.options.JOptionDialog.java

private void jspMaxRecNumberStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jspMaxRecNumberStateChanged
    JSpinner s = (JSpinner) evt.getSource();
    SpinnerNumberModel m = (SpinnerNumberModel) s.getModel();
    pref.putInt("maxrecnumber", m.getNumber().intValue());
}

From source file:de.unibayreuth.bayeos.goat.options.JOptionDialog.java

private void jspGapThresholdStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jspGapThresholdStateChanged
    JSpinner s = (JSpinner) evt.getSource();
    SpinnerNumberModel m = (SpinnerNumberModel) s.getModel();
    pref.putDouble("chartthreshold", m.getNumber().doubleValue());
}

From source file:de.atomfrede.tools.evalutation.options.ui.OptionsDialog.java

private JSpinner getSampleSpinner() {
    if (sampleSpinner == null) {
        sampleSpinner = new JSpinner();
        SpinnerNumberModel numberModel = new SpinnerNumberModel(TypeAEvaluationOptions.getSampleRate(), 1.0,
                10.0, 1.0);/*from  ww  w.  j  av a  2  s  .co  m*/
        sampleSpinner.setModel(numberModel);

        sampleSpinner.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                SpinnerNumberModel model = (SpinnerNumberModel) sampleSpinner.getModel();
                double selectedValue = model.getNumber().doubleValue();
                sampleRate = selectedValue;

            }
        });
    }
    return sampleSpinner;
}

From source file:pl.otros.logview.gui.actions.StartSocketListener.java

private LogImporterAndPort chooseLogImporter() {
    Collection<LogImporter> elements = AllPluginables.getInstance().getLogImportersContainer().getElements();
    LogImporter[] importers = elements.toArray(new LogImporter[0]);
    String[] names = new String[elements.size()];
    for (int i = 0; i < names.length; i++) {
        names[i] = importers[i].getName();
    }/*  www . j av  a 2s  . com*/

    JComboBox box = new JComboBox(names);
    SpinnerNumberModel numberModel = new SpinnerNumberModel(50505, 1025, 65000, 1);
    JSpinner jSpinner = new JSpinner(numberModel);
    MigLayout migLayout = new MigLayout();
    JPanel panel = new JPanel(migLayout);
    panel.add(new JLabel("Select log importer"));
    panel.add(box, "wrap");
    panel.add(new JLabel("Select port"));
    panel.add(jSpinner, "span");

    if (logReaders.size() > 0) {
        panel.add(new JLabel("Opened sockets"), "wrap, growx");
        JTable jTable = new JTable(logReaders.size(), 2);
        jTable.getTableHeader().getColumnModel().getColumn(0).setHeaderValue("Log importer");
        jTable.getTableHeader().getColumnModel().getColumn(1).setHeaderValue("Port");
        int row = 0;
        for (SocketLogReader socketLogReader : logReaders) {
            jTable.setValueAt(socketLogReader.getLogImporter().getName(), row, 0);
            jTable.setValueAt(Integer.toString(socketLogReader.getPort()), row, 1);
            row++;
        }
        JScrollPane jScrollPane = new JScrollPane(jTable);
        panel.add(jScrollPane, "wrap, span");
    }
    int showConfirmDialog = JOptionPane.showConfirmDialog(null, panel, "Choose log importer and port",
            JOptionPane.OK_CANCEL_OPTION);
    if (showConfirmDialog != JOptionPane.OK_OPTION) {
        return null;
    }

    return new LogImporterAndPort(importers[box.getSelectedIndex()], numberModel.getNumber().intValue());
}