deal with some additional focus issues

This commit is contained in:
benfry
2011-04-10 18:19:39 +00:00
parent 5ae4534378
commit 02b370d9db
2 changed files with 10 additions and 8 deletions
+8 -7
View File
@@ -222,14 +222,15 @@ public abstract class Editor extends JFrame implements RunnerListener {
// Bring back the general options for the editor
applyPreferences();
// Recommendation, but doesn't seem to do much for us
// http://download.oracle.com/javase/tutorial/uiswing/misc/focus.html
// Make textField get the focus whenever frame is activated.
// addWindowFocusListener(new WindowAdapter() {
// public void windowGainedFocus(WindowEvent e) {
// textarea.requestFocusInWindow();
// }
// });
// http://download.oracle.com/javase/tutorial/uiswing/misc/focus.html
// May not be necessary, but helps avoid random situations with
// the editor not being able to request its own focus.
addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
textarea.requestFocusInWindow();
}
});
// Open the document that was passed in
boolean loaded = handleOpenInternal(path);
+2 -1
View File
@@ -134,7 +134,7 @@ public class EditorStatus extends JPanel {
editField.setVisible(true);
editField.setText(dflt);
editField.selectAll();
editField.requestFocus();
editField.requestFocusInWindow();
repaint();
}
@@ -144,6 +144,7 @@ public class EditorStatus extends JPanel {
okButton.setVisible(false);
cancelButton.setVisible(false);
editField.setVisible(false);
editor.textarea.requestFocusInWindow();
empty();
}