default focus on text when editing JLabel

This commit is contained in:
bancika
2017-01-05 10:35:20 +01:00
parent 23d702eeb5
commit 53f09e6143
6 changed files with 31 additions and 19 deletions
@@ -116,12 +116,20 @@ public class PropertyEditorDialog extends ButtonDialog {
editorPanel.add(createDefaultCheckBox(property), gbc);
}
}
// Make value field focused
if (property.getName().equalsIgnoreCase("value")) {
componentToFocus = editor;
}
// Make value field focused
try {
if (componentToFocus == null && property.getGetter().getName().equalsIgnoreCase("getValue")) {
componentToFocus = editor;
}
} catch (Exception e1) {
LOG.warn("Could not determine editor component to focus", e1);
}
gbc.gridy++;
}
@@ -48,4 +48,10 @@ public class StringEditor extends JTextField {
setBackground(oldBg);
property.setValue(getText());
}
@Override
public boolean requestFocusInWindow() {
selectAll();
return super.requestFocusInWindow();
}
}