use of com.att.aro.ui.utils.NumericInputVerifier in project VideoOptimzer by attdevsupport.
the class PreferencesDialog method getValuePanel.
private Component getValuePanel(final Config config) {
int fieldHeight = Util.isLinuxOS() ? 28 : 20;
JPanel panel = new JPanel();
Dimension size = new Dimension(300, fieldHeight);
panel.setLayout(new BoxLayout(panel, LINE_AXIS));
setSize(panel, size);
if (config.getConfigType() == ConfigType.TEXT) {
panel.add(getValueTextField(config, size));
} else if (config.getConfigType() == ConfigType.MEMORY || config.getConfigType() == ConfigType.NUMBER) {
double maximumValue = 1;
JTextField textField = getValueTextField(config, size);
if (config.getConfigType() == ConfigType.MEMORY) {
maximumValue = ((JvmSettings) JvmSettings.getInstance()).getMaximumMemoryGB();
}
textField.setInputVerifier(new NumericInputVerifier(maximumValue, 2, 1, false, this));
textField.addKeyListener(getKeyListener(textField));
textField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (hider != null) {
closePopup();
}
}
@Override
public void focusGained(FocusEvent e) {
}
});
panel.add(textField);
} else if (config.getConfigType() == ConfigType.FILE) {
Dimension txtSize = new Dimension(220, fieldHeight);
final JTextField textField = getValueTextField(config, txtSize);
Dimension btnSize = new Dimension(75, fieldHeight);
JButton btnBrowse = new JButton("Browse");
setSize(btnBrowse, btnSize);
btnBrowse.addActionListener((ActionEvent e) -> setPathTextField(textField));
panel.add(textField);
panel.add(btnBrowse);
} else if (config.getConfigType() == ConfigType.COMBO) {
JComboBox<String> comboBox = new JComboBox<>(getComboValue(config));
comboBox.addActionListener((ActionEvent e) -> setLoggingLvl((String) comboBox.getSelectedItem()));
comboBox.setSelectedItem(Util.getLoggingLevel());
panel.add(comboBox);
}
return panel;
}
use of com.att.aro.ui.utils.NumericInputVerifier in project VideoOptimzer by attdevsupport.
the class VideoPreferencesPanel method getVideoPrefencesPanel.
private Component getVideoPrefencesPanel() {
stallTriggerTimeEdit = new JTextField(String.format("%.3f", videoUsagePrefs.getStallTriggerTime()), 5);
maxBufferEdit = new JTextField(String.format("%.2f", videoUsagePrefs.getMaxBuffer()), 5);
stallPausePointEdit = new JTextField(String.format("%.4f", videoUsagePrefs.getStallPausePoint()), 5);
stallRecoveryEdit = new JTextField(String.format("%.4f", videoUsagePrefs.getStallRecovery()), 5);
targetedStartupDelayEdit = new JTextField(String.format("%.2f", videoUsagePrefs.getStartupDelay()), 5);
nearStallEdit = new JTextField(String.format("%.4f", videoUsagePrefs.getNearStall()), 5);
stallTriggerTimeEdit.setInputVerifier(getNumericInputVerifier(MAX_STALLTRIGGERTIME, 0.01, 3));
stallTriggerTimeEdit.addKeyListener(getKeyListener(stallTriggerTimeEdit));
maxBufferEdit.setInputVerifier(getNumericInputVerifier(MAX_BUFFER, 0, 2));
maxBufferEdit.addKeyListener(getKeyListener(maxBufferEdit));
stallPausePointEdit.setInputVerifier(getNumericInputVerifier(MAX_STALLRECOVERY, 0, 4));
stallPausePointEdit.addKeyListener(getKeyListener(stallPausePointEdit));
stallRecoveryEdit.setInputVerifier(getNumericInputVerifier(MAX_STALLRECOVERY, 0, 4));
stallRecoveryEdit.addKeyListener(getKeyListener(stallRecoveryEdit));
targetedStartupDelayEdit.setInputVerifier(getNumericInputVerifier(MAX_TARGETEDSTARTUPDELAY, 0, 2));
targetedStartupDelayEdit.addKeyListener(getKeyListener(targetedStartupDelayEdit));
NumericInputVerifier numericInputVerifier = getNumericInputVerifier(MAX_NEARSTALL, 0.01, 4);
nearStallEdit.setInputVerifier(numericInputVerifier);
nearStallEdit.addKeyListener(getKeyListener(nearStallEdit));
startupDelayReminder = new JCheckBox();
duplicateHandlingEditCombo = new JComboBox<>();
for (DUPLICATE_HANDLING item : DUPLICATE_HANDLING.values()) {
duplicateHandlingEditCombo.addItem(item);
}
duplicateHandlingEditCombo.setSelectedItem(videoUsagePrefs.getDuplicateHandling());
idx = 0;
GridBagLayout gridBagLayout = new GridBagLayout();
JPanel panel = new JPanel(gridBagLayout);
panel.setAlignmentX(CENTER_ALIGNMENT);
panel.setBorder(new RoundedBorder(new Insets(10, 10, 10, 10), null));
addVideoPreference(panel);
addDefaultButton(panel, 2, numericInputVerifier);
return panel;
}
Aggregations