Example usage for javax.swing SpinnerNumberModel SpinnerNumberModel

List of usage examples for javax.swing SpinnerNumberModel SpinnerNumberModel

Introduction

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

Prototype

public SpinnerNumberModel() 

Source Link

Document

Constructs a SpinnerNumberModel with no minimum or maximum value, stepSize equal to one, and an initial value of zero.

Usage

From source file:Tcpbw100.java

public void init() {

    //added applet parameters (country,language) to directly influence the language displayed
    if (getParameter("country") != null)
        country = getParameter("country");
    if (getParameter("language") != null)
        lang = getParameter("language");
    if (getParameter("client") != null)
        applet_id = getParameter("client");
    // try to load the appropriate resource files
    try {//w ww  .j  ava  2  s.  co  m
        locale = new Locale(lang, country);
        System.out.println("Interface language set to " + locale.getLanguage() + "_" + locale.getCountry());
        messages = ResourceBundle.getBundle("Tcpbw100_msgs", locale);
        res = ResourceBundle.getBundle("strings", locale);
        System.out.println("language loaded is :" + res.getLocale());
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Error while loading language files:\n" + e.getMessage());
        e.printStackTrace();
    }

    JPanel advancedPanel = new JPanel(new BorderLayout());
    final CardLayout cards = new CardLayout();
    getContentPane().setLayout(cards);

    final JFrame popout = new JFrame("Network Diagnostic Tool");
    popout.add(advancedPanel);
    popout.pack();

    //blank the labels
    reset_labels();

    showStatus(messages.getString("ready"));
    failed = false;
    Randomize = false;
    cancopy = false;
    results = new MyTextPane();
    results.append("TCP/Web100 Network Diagnostic Tool v" + VERSION + "\n");
    results.setEditable(false);
    advancedPanel.add(new JScrollPane(results), BorderLayout.CENTER);
    results.append(messages.getString("clickStart") + "\n");
    Panel mPanel = new Panel();
    startTest = new JButton(messages.getString("start"));
    startTest.addActionListener(this);
    startTest2 = new JButton(res.getString("start"));
    startTest2.addActionListener(this);

    //mPanel.add(startTest);
    sTatistics = new JButton(messages.getString("statistics"));
    sTatistics.addActionListener(this);
    if (getParameter("disableStatistics") == null) {
        mPanel.add(sTatistics);
    }
    sTatistics.setEnabled(false);
    deTails = new JButton(messages.getString("moreDetails"));
    deTails.addActionListener(this);
    if (getParameter("disableDetails") == null) {
        mPanel.add(deTails);
    }
    deTails.setEnabled(false);
    mailTo = new JButton(messages.getString("reportProblem"));
    mailTo.addActionListener(this);
    if (getParameter("disableMailto") == null) {
        //mPanel.add(mailTo);
    }
    mailTo.setEnabled(false);
    options = new JButton(messages.getString("options") + "...");
    options.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            options.setEnabled(false);
            showOptions();
            options.setEnabled(true);
        }

    });
    if (getParameter("disableOptions") == null) {
        mPanel.add(options);
    }
    advancedPanel.add(mPanel, BorderLayout.SOUTH);
    preferIPv6 = new JCheckBox(messages.getString("preferIPv6"));
    preferIPv6.setSelected(true);
    defaultTest = new JCheckBox(messages.getString("defaultTests"));
    defaultTest.setSelected(true);
    defaultTest.setEnabled(false);
    SpinnerNumberModel model = new SpinnerNumberModel();
    model.setMinimum(new Integer(0));
    model.setValue(new Integer(1));
    numOfTests.setModel(model);
    numOfTests.setPreferredSize(new Dimension(60, 20));
    delay = new JComboBox();
    for (int i = 0; i < delays.length; i++) {
        delay.addItem(messages.getString(delays[i]));
    }
    delay.setSelectedIndex(0);

    //Autorun functionality
    isAutoRun = getParameter("autoRun");
    if ((isAutoRun != null) && isAutoRun.equals("true")) {
        pub_errmsg = "Test in progress.";
        runtest();
    }
    //@@@ getContentPane().add(advancedPanel,"");

    //try to load the calibri font for the simplified interface.
    //this will not cause problems even if said font is not available
    Font very_small_font = new Font("Calibri", Font.PLAIN, 6);
    Font small_font = new Font("Calibri", Font.PLAIN, 14);
    Font big_font = new Font("Calibri", Font.PLAIN, 18);

    startTest2.setFont(small_font);

    //simplePanel will be the new face of the applet
    JPanel simplePanel = new JPanel();

    simplePanel.setLayout(null);
    simplePanel.setBackground(Color.WHITE);
    //simplePanel.setLayout(new BorderLayout());
    simplePanel.add(simple_progressBar, BorderLayout.SOUTH);
    getContentPane().add(simplePanel, "");
    cards.last(getContentPane());
    simple_progressBar.setMaximum(10);
    simple_progressBar.setBounds(3, 135, 394, 23);
    simple_progressBar.setFont(small_font);

    //simple_progressBar.setIndeterminate(true);
    simple_progressBar.setIndeterminate(false);
    simple_progressBar.setValue(0);
    simple_progressBar.setStringPainted(true);
    simple_progressBar.setString(res.getString("ready_to_measure"));

    //position the startTest2 button explicitly
    //was: simplePanel.add(startTest2,BorderLayout.NORTH);
    simplePanel.add(startTest2, "");
    startTest2.setBounds(3, 164, 195, 30);

    final class switcherListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
            //@@@cards.next(getContentPane());
            if (popout.isVisible()) {
                popout.setVisible(false);
            } else {
                popout.setVisible(true);
                popout.pack();
            }

        }

    }

    //"show details button" - activates the classic NDT interface 
    JButton switchPane = new JButton(res.getString("show_details"));
    switchPane.setFont(small_font);

    switchPane.addActionListener(new switcherListener());
    simplePanel.add(switchPane, "");
    switchPane.setBounds(202, 164, 195, 30);

    //masterArea, displays the measurement characteristics
    JPanel masterArea = new JPanel(new GridLayout(0, 2));

    //position explicitly
    simplePanel.add(masterArea, "");
    masterArea.setBounds(1, 1, 398, 130);
    masterArea.setBackground(Color.WHITE);

    //create the 5 tags that will be placed in the masterArea
    JLabel dnlTag = new JLabel(res.getString("download"));
    JLabel uplTag = new JLabel(res.getString("upload"));
    JLabel rttTag = new JLabel(res.getString("ping"));
    JLabel lossTag = new JLabel(res.getString("loss"));
    JLabel jitterTag = new JLabel(res.getString("jitter"));

    //make the masterAre pretty  
    dnlTag.setHorizontalAlignment(JLabel.RIGHT);
    uplTag.setHorizontalAlignment(JLabel.RIGHT);
    rttTag.setHorizontalAlignment(JLabel.RIGHT);
    lossTag.setHorizontalAlignment(JLabel.RIGHT);
    jitterTag.setHorizontalAlignment(JLabel.RIGHT);

    dnlTag.setFont(big_font);
    uplTag.setFont(big_font);
    rttTag.setFont(big_font);
    lossTag.setFont(big_font);
    jitterTag.setFont(big_font);

    dnlLbl.setHorizontalAlignment(JLabel.LEFT);
    uplLbl.setHorizontalAlignment(JLabel.LEFT);
    rttLbl.setHorizontalAlignment(JLabel.LEFT);
    lossLbl.setHorizontalAlignment(JLabel.LEFT);
    jitterLbl.setHorizontalAlignment(JLabel.LEFT);

    dnlLbl.setFont(big_font);
    uplLbl.setFont(big_font);
    rttLbl.setFont(big_font);
    lossLbl.setFont(big_font);
    jitterLbl.setFont(big_font);

    //and finally, place the labels
    masterArea.add(dnlTag);
    masterArea.add(dnlLbl);
    masterArea.add(uplTag);
    masterArea.add(uplLbl);
    masterArea.add(rttTag);
    masterArea.add(rttLbl);
    masterArea.add(lossTag);
    masterArea.add(lossLbl);
    masterArea.add(jitterTag);
    masterArea.add(jitterLbl);

    // determine whether to prefer IPv6 or not, this is done only once
    if (getParameter("disable_ipv6") != null) {
        preferIPv6.setSelected(false);
    }

}

From source file:org.gitools.ui.app.analysis.groupcomparison.wizard.GroupComparisonGroupingPage.java

public GroupComparisonGroupingPage(Heatmap heatmap, DimensionGroupEnum groupingType) {
    super();/*from  ww w  .  ja  va2  s  . c  o  m*/

    this.heatmap = heatmap;
    this.groupingType = groupingType;

    setLogo(IconUtils.getImageIconResourceScaledByHeight(IconNames.LOGO_METHOD, 96));

    layerCb.setModel(new DefaultComboBoxModel(heatmap.getLayers().getIds()));
    layerCb.setSelectedItem(heatmap.getLayers().getTopLayer().getId());

    groupsTable.setModel(tableModel);

    setTitle("Group selection");
    TableColumnModel columnModel = groupsTable.getColumnModel();
    columnModel.getColumn(2).setPreferredWidth(50);
    columnModel.getColumn(2).setCellEditor(new SpinnerCellEditor(new SpinnerNumberModel()));
    columnModel.getColumn(2).getCellEditor().addCellEditorListener(new CellEditorListener() {
        @Override
        public void editingStopped(ChangeEvent e) {
            tableModel.fireTableDataChanged();
        }

        @Override
        public void editingCanceled(ChangeEvent e) {
            tableModel.fireTableDataChanged();
        }
    });
    groupsTable.setRowHeight(25);

    groupsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            updateControls();
        }
    });

    removeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            removeSelected();
        }
    });

    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (getSelectedGroupingType().equals(DimensionGroupEnum.Annotation)) {
                //TODO: create Dialog with removedItems
            } else if (getSelectedGroupingType().equals(DimensionGroupEnum.Free)) {
                createFreeGroup();
            } else if (getSelectedGroupingType().equals(DimensionGroupEnum.Value)) {
                createValueGroup();
            }
            updateControls();
        }
    });

    dimensionCb.setModel(new DefaultComboBoxModel(new String[] { "Columns", "Rows" }));

    mergeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            performMerge();
        }
    });
    splitButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            performSplit();
        }
    });
    dimensionCb.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            initGroups();
        }
    });

    ActionListener listener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            initGroups();
        }
    };
    annotationRadioButton.addActionListener(listener);
    valueRadioButton.addActionListener(listener);
    noConstraintRadioButton.addActionListener(listener);

    ActionListener nullConversionListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateControls();
        }
    };
    nullDiscardRadioButton.addActionListener(nullConversionListener);
    nullConversionRadioButton.addActionListener(nullConversionListener);

    nullConversionTextArea.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            updateControls();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            updateControls();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateControls();
        }
    });

    updateControls();

    layerCb.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateControls();
        }
    });
}