Search in sources :

Example 41 with JSpinner

use of javax.swing.JSpinner in project ACS by ACS-Community.

the class BeanGrouper method getTimeSampSpinner.

/**
	 * Initializes the TextField that will allow to input the desired Sampling Time for the Sampling Group.<br>
	 * By default the value is 0, which means infinite time (or until stop button is pressed).<br>
	 * Also checks for its correctness when the value changes.
	 * @return javax.swing.JTextField Reference to the Text Field containing the number.
	 */
private JSpinner getTimeSampSpinner() {
    if (timeSampSpinner == null) {
        timeSampSpinner = new JSpinner();
        timeSampSpinner.setModel(new SpinnerNumberModel(0, 0, 1000, 1));
        timeSampSpinner.setToolTipText("How long, in minutes, will the sampling last. A value of 0 means non-stopping sample.");
    }
    return timeSampSpinner;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JSpinner(javax.swing.JSpinner)

Example 42 with JSpinner

use of javax.swing.JSpinner in project adempiere by adempiere.

the class MinuteModel method jbInit.

/**
	 *	Static init
	 *  @throws Exception
	 */
private void jbInit() throws Exception {
    this.addKeyListener(this);
    //
    mainPanel.setLayout(mainLayout);
    mainLayout.setHgap(2);
    mainLayout.setVgap(2);
    //mainPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 2));
    getContentPane().add(mainPanel);
    //	Month Panel
    monthPanel.setLayout(monthLayout);
    monthPanel.add(bBack, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    monthPanel.add(cYear, new GridBagConstraints(3, 0, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
    monthPanel.add(bNext, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    monthPanel.add(cMonth, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    monthPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
    mainPanel.add(monthPanel, BorderLayout.NORTH);
    cMonth.addActionListener(this);
    cYear.addChangeListener(this);
    //  <
    bBack.setIcon(Env.getImageIcon("Parent16.gif"));
    bBack.setMargin(new Insets(0, 0, 0, 0));
    bBack.addActionListener(this);
    //   >
    bNext.setIcon(Env.getImageIcon("Detail16.gif"));
    bNext.setMargin(new Insets(0, 0, 0, 0));
    bNext.addActionListener(this);
    //	Day Panel
    dayPanel.setLayout(dayLayout);
    dayLayout.setColumns(7);
    dayLayout.setHgap(2);
    dayLayout.setRows(7);
    dayLayout.setVgap(2);
    dayPanel.setBackground(Color.white);
    dayPanel.setOpaque(true);
    mainPanel.add(dayPanel, BorderLayout.CENTER);
    //	Time Panel
    timePanel.setLayout(timeLayout);
    lTimeSep.setText(" : ");
    timePanel.add(fHour, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 0), 0, 0));
    timePanel.add(lTimeSep, new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    timePanel.add(fMinute, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    timePanel.add(cbPM, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));
    timePanel.add(lTZ, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 0, 0));
    timePanel.add(bOK, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 6, 0, 2), 0, 0));
    mainPanel.add(timePanel, BorderLayout.SOUTH);
    //	Enter returns
    fHour.addKeyListener(this);
    // JSpinner ignores KeyListener
    ((JSpinner.DefaultEditor) fMinute.getEditor()).getTextField().addKeyListener(this);
    fMinute.addChangeListener(this);
    cbPM.addActionListener(this);
    cbPM.addKeyListener(this);
    bOK.setIcon(Env.getImageIcon("Ok16.gif"));
    bOK.setMargin(new Insets(0, 1, 0, 1));
    bOK.addActionListener(this);
    AutoCompletion.enable(fHour);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JSpinner(javax.swing.JSpinner)

Example 43 with JSpinner

use of javax.swing.JSpinner in project jdk8u_jdk by JetBrains.

the class InsetsEncapsulation method run.

@Override
public void run() {
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    runTest(new JScrollBar());
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) JTextArea(javax.swing.JTextArea) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTableHeader(javax.swing.table.JTableHeader) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JScrollBar(javax.swing.JScrollBar) JTextPane(javax.swing.JTextPane) JToggleButton(javax.swing.JToggleButton) JSlider(javax.swing.JSlider) JMenuItem(javax.swing.JMenuItem) JComponent(javax.swing.JComponent) Component(java.awt.Component) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JToolBar(javax.swing.JToolBar) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) JTable(javax.swing.JTable) JEditorPane(javax.swing.JEditorPane) JSpinner(javax.swing.JSpinner) JRootPane(javax.swing.JRootPane) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 44 with JSpinner

use of javax.swing.JSpinner in project JMRI by JMRI.

the class JsonServerPreferencesPanel method portPanel.

private JPanel portPanel() {
    JPanel panel = new JPanel();
    port = new JSpinner(new SpinnerNumberModel(JsonServerPreferences.DEFAULT_PORT, 1, 65535, 1));
    ((JSpinner.DefaultEditor) port.getEditor()).getTextField().setEditable(true);
    port.setEditor(new JSpinner.NumberEditor(port, "#"));
    this.port.addChangeListener((ChangeEvent e) -> {
        this.setValues();
    });
    this.port.setToolTipText(Bundle.getMessage("PortToolTip"));
    panel.add(port);
    JLabel label = new JLabel(Bundle.getMessage("LabelPort"));
    label.setToolTipText(this.port.getToolTipText());
    panel.add(label);
    return panel;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) ChangeEvent(javax.swing.event.ChangeEvent) JSpinner(javax.swing.JSpinner) JLabel(javax.swing.JLabel)

Example 45 with JSpinner

use of javax.swing.JSpinner in project JMRI by JMRI.

the class JsonServerPreferencesPanel method heartbeatPanel.

private JPanel heartbeatPanel() {
    JPanel panel = new JPanel();
    heartbeatIntervalSpinner = new JSpinner(new SpinnerNumberModel(15, MIN_HEARTBEAT_INTERVAL, MAX_HEARTBEAT_INTERVAL, 1));
    ((JSpinner.DefaultEditor) heartbeatIntervalSpinner.getEditor()).getTextField().setEditable(true);
    this.heartbeatIntervalSpinner.addChangeListener((ChangeEvent e) -> {
        this.setValues();
    });
    this.heartbeatIntervalSpinner.setToolTipText(Bundle.getMessage("HeartbeatToolTip", MIN_HEARTBEAT_INTERVAL, MAX_HEARTBEAT_INTERVAL));
    panel.add(heartbeatIntervalSpinner);
    JLabel label = new JLabel(Bundle.getMessage("HeartbeatLabel"));
    label.setToolTipText(this.heartbeatIntervalSpinner.getToolTipText());
    panel.add(label);
    return panel;
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) ChangeEvent(javax.swing.event.ChangeEvent) JSpinner(javax.swing.JSpinner) JLabel(javax.swing.JLabel)

Aggregations

JSpinner (javax.swing.JSpinner)76 SpinnerNumberModel (javax.swing.SpinnerNumberModel)61 JLabel (javax.swing.JLabel)47 JPanel (javax.swing.JPanel)41 ActionEvent (java.awt.event.ActionEvent)28 ActionListener (java.awt.event.ActionListener)27 JCheckBox (javax.swing.JCheckBox)22 JRadioButton (javax.swing.JRadioButton)21 GridBagConstraints (java.awt.GridBagConstraints)18 Insets (java.awt.Insets)18 ChangeEvent (javax.swing.event.ChangeEvent)18 GridBagLayout (java.awt.GridBagLayout)17 JButton (javax.swing.JButton)15 Dimension (java.awt.Dimension)13 ChangeListener (javax.swing.event.ChangeListener)13 ButtonGroup (javax.swing.ButtonGroup)12 BorderLayout (java.awt.BorderLayout)11 JTextField (javax.swing.JTextField)11 JScrollPane (javax.swing.JScrollPane)10 JMenuItem (javax.swing.JMenuItem)8