Save text configuration value on enter

To make the behaviour consistent with the spinners, save configuration
value of text field when user presses enter.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-04-01 08:24:44 +02:00
parent a24b7b427e
commit 1e9fba6a52

View File

@@ -29,8 +29,8 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -412,13 +412,9 @@ public class ConfigPanel extends PluginPanel
{
JTextField textField = new JTextField("", TEXT_FIELD_WIDTH);
textField.setText(configManager.getConfiguration(cd.getGroup().keyName(), cid.getItem().keyName()));
textField.addFocusListener(new FocusListener()
{
@Override
public void focusGained(FocusEvent e)
{
}
textField.addFocusListener(new FocusAdapter()
{
@Override
public void focusLost(FocusEvent e)
{
@@ -426,6 +422,13 @@ public class ConfigPanel extends PluginPanel
textField.setToolTipText(textField.getText());
}
});
textField.addActionListener(e ->
{
changeConfiguration(textField, cd, cid);
textField.setToolTipText(textField.getText());
});
textField.setToolTipText(textField.getText());
item.add(textField, BorderLayout.EAST);
}