Skip to content

Commit

Permalink
fixed focus problem with new password dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Kramer committed Mar 26, 2015
1 parent 19a4de0 commit d030d4c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions kse/src/net/sf/keystore_explorer/gui/password/DGetNewPassword.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;

import net.sf.keystore_explorer.crypto.Password;
import net.sf.keystore_explorer.gui.JEscDialog;
Expand Down Expand Up @@ -229,12 +230,21 @@ public void windowClosing(WindowEvent evt) {
setResizable(false);

getRootPane().setDefaultButton(jbOK);

pack();

SwingUtilities.invokeLater(new Runnable() {
public void run() {
jpfFirst.requestFocus();
// fix for focus issues: request focus after dialog was made visible
jpfFirst.addAncestorListener(new AncestorListener() {
@Override
public void ancestorRemoved(AncestorEvent event) {
}
@Override
public void ancestorMoved(AncestorEvent event) {
}
@Override
public void ancestorAdded(AncestorEvent event) {
JComponent component = event.getComponent();
component.requestFocusInWindow();
}
});
}
Expand Down

0 comments on commit d030d4c

Please sign in to comment.