Skip to content

Commit

Permalink
Display unit in interval and timeout spinners
Browse files Browse the repository at this point in the history
  • Loading branch information
bwRavencl committed Oct 13, 2019
1 parent 1a2b21f commit 30ce926
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/de/bwravencl/controllerbuddy/gui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,8 @@ public void windowOpened(final WindowEvent e) {

final var pollIntervalSpinner = new JSpinner(new SpinnerNumberModel(
preferences.getInt(PREFERENCES_POLL_INTERVAL, OutputThread.DEFAULT_POLL_INTERVAL), 1, 100, 1));
final JSpinner.DefaultEditor pollIntervalSpinnerEditor = new JSpinner.NumberEditor(pollIntervalSpinner, "#");
final var pollIntervalSpinnerEditor = new JSpinner.NumberEditor(pollIntervalSpinner,
"# " + rb.getString("MILLISECOND_SYMBOL"));
((DefaultFormatter) pollIntervalSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true);
pollIntervalSpinner.setEditor(pollIntervalSpinnerEditor);
pollIntervalSpinner.addChangeListener(
Expand Down Expand Up @@ -1102,7 +1103,7 @@ public void windowOpened(final WindowEvent e) {

final var vJoyDeviceSpinner = new JSpinner(new SpinnerNumberModel(
preferences.getInt(PREFERENCES_VJOY_DEVICE, VJoyOutputThread.DEFAULT_VJOY_DEVICE), 1, 16, 1));
final JSpinner.DefaultEditor vJoyDeviceSpinnerEditor = new JSpinner.NumberEditor(vJoyDeviceSpinner, "#");
final var vJoyDeviceSpinnerEditor = new JSpinner.NumberEditor(vJoyDeviceSpinner, "#");
((DefaultFormatter) vJoyDeviceSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true);
vJoyDeviceSpinner.setEditor(vJoyDeviceSpinnerEditor);
vJoyDeviceSpinner.addChangeListener(
Expand All @@ -1116,7 +1117,7 @@ public void windowOpened(final WindowEvent e) {
hostLabel.setPreferredSize(new Dimension(120, 15));
hostPanel.add(hostLabel);

hostTextField = new JTextField(preferences.get(PREFERENCES_HOST, ClientVJoyOutputThread.DEFAULT_HOST), 10);
hostTextField = new JTextField(preferences.get(PREFERENCES_HOST, ClientVJoyOutputThread.DEFAULT_HOST), 15);
final var setHostAction = new SetHostAction(hostTextField);
hostTextField.addActionListener(setHostAction);
hostTextField.addFocusListener(setHostAction);
Expand All @@ -1132,7 +1133,7 @@ public void windowOpened(final WindowEvent e) {

final var portSpinner = new JSpinner(new SpinnerNumberModel(
preferences.getInt(PREFERENCES_PORT, ServerOutputThread.DEFAULT_PORT), 1024, 65535, 1));
final JSpinner.DefaultEditor portSpinnerEditor = new JSpinner.NumberEditor(portSpinner, "#");
final var portSpinnerEditor = new JSpinner.NumberEditor(portSpinner, "#");
((DefaultFormatter) portSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true);
portSpinner.setEditor(portSpinnerEditor);
portSpinner.addChangeListener(
Expand All @@ -1148,7 +1149,8 @@ public void windowOpened(final WindowEvent e) {

final var timeoutSpinner = new JSpinner(new SpinnerNumberModel(
preferences.getInt(PREFERENCES_TIMEOUT, ServerOutputThread.DEFAULT_TIMEOUT), 10, 60000, 1));
final JSpinner.DefaultEditor timeoutSpinnerEditor = new JSpinner.NumberEditor(timeoutSpinner, "#");
final var timeoutSpinnerEditor = new JSpinner.NumberEditor(timeoutSpinner,
"# " + rb.getString("MILLISECOND_SYMBOL"));
((DefaultFormatter) timeoutSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true);
timeoutSpinner.setEditor(timeoutSpinnerEditor);
timeoutSpinner.addChangeListener(
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,5 @@ BATTERY_TOOLTIP_PREFIX = \nBattery:\u0020
BATTERY_TOOLTIP_CHARGING_SUFFIX = % (charging)
BATTERY_TOOLTIP_DISCHARGING_SUFFIX = % (discharging)
LOW_BATTERY_CAPTION = Low Battery
MILLISECOND_SYMBOL = ms

0 comments on commit 30ce926

Please sign in to comment.