use of javax.swing.SpinnerNumberModel in project ACS by ACS-Community.
the class BeanGrouper method getFreqSpinner.
/**
* Initializes the TextField that will allow to input the desired Frequency for the Sampling Group.<br>
* By default the value is 10 Hz.<br>
* Also checks for its correctness when the value changes.
* @return javax.swing.JTextField Reference to the Text Field containing the number.
*/
private JSpinner getFreqSpinner() {
if (freqSpinner == null) {
freqSpinner = new JSpinner();
freqSpinner.setToolTipText("How often, in herz, will the sampling occur.");
freqSpinner.setModel(new SpinnerNumberModel(1, 0.1, 20.0, 0.1));
freqSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
for (DataPrinter dp : samplers) {
double freq = ((SpinnerNumberModel) freqSpinner.getModel()).getNumber().doubleValue();
dp.setFrequency(freq);
}
}
});
}
return freqSpinner;
}
use of javax.swing.SpinnerNumberModel 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;
}
use of javax.swing.SpinnerNumberModel 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;
}
use of javax.swing.SpinnerNumberModel 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;
}
use of javax.swing.SpinnerNumberModel in project JMRI by JMRI.
the class CoordinateEdit method initFixedSize.
public void initFixedSize() {
PositionablePopupUtil util = pl.getPopupUtility();
oldX = util.getFixedHeight();
oldY = util.getFixedWidth();
textX = new javax.swing.JLabel();
textX.setText("Height = " + util.getFixedHeight());
textX.setVisible(true);
textY = new javax.swing.JLabel();
textY.setText("Width = " + util.getFixedWidth());
textY.setVisible(true);
SpinnerNumberModel model = new SpinnerNumberModel(0, 0, 1000, 1);
spinX = new javax.swing.JSpinner(model);
spinX.setValue(Integer.valueOf(util.getFixedHeight()));
spinX.setToolTipText(Bundle.getMessage("FixedSizeHeight"));
spinX.setMaximumSize(new Dimension(spinX.getMaximumSize().width, spinX.getPreferredSize().height));
model = new javax.swing.SpinnerNumberModel(0, 0, 1000, 1);
spinY = new javax.swing.JSpinner(model);
spinY.setValue(Integer.valueOf(util.getFixedWidth()));
spinY.setToolTipText(Bundle.getMessage("FixedSizeWidth"));
spinY.setMaximumSize(new Dimension(spinY.getMaximumSize().width, spinY.getPreferredSize().height));
getContentPane().setLayout(new GridBagLayout());
addSpinItems(true);
okButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
int height = ((Number) spinX.getValue()).intValue();
int width = ((Number) spinY.getValue()).intValue();
PositionablePopupUtil util = pl.getPopupUtility();
util.setFixedSize(width, height);
pl.getEditor().setAttributes(util, pl);
textX.setText("Height: " + util.getFixedHeight());
textY.setText("Width: " + util.getFixedWidth());
dispose();
}
});
okButton.getRootPane().setDefaultButton(okButton);
cancelButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
pl.getPopupUtility().setFixedSize(oldY, oldX);
dispose();
}
});
pack();
}
Aggregations