-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.4, 1.1.6, 1.1.7, 1.2.0
-
x86
-
windows_nt
Name: tb29552 Date: 10/01/98
/*
Run the test code below, which works under 1.1.6 but
not under 1.1.7.
The intention of the code in the WindowOpened event is
to try to find the current username by querying the
system properties, automatically enter it into the
userid textfield, and then setting focus to the
password textfield. If no userid is found, focus
should be set at the userid textfield.
Under 1.1.6, the passwordTextField.requestFocus() call
properly sets focus to the password textfield when a
username is found. Under 1.1.7, the
passwordTextField.requestFocus() method is called, but
focus does not get set to the password TextField.
Please advise about any workarounds or proper ways of
accomplishing this in 1.1.7.
Sample code:
------------
*/
import java.awt.*;
import java.awt.event.*;
public class TestFrame extends Frame implements WindowListener {
private Label PasswordLabel = new Label("Password:");
private TextField PasswordTextField = new TextField();
private Label UserIdLabel = new Label("UserId:");
private TextField UserIdTextField = new TextField();
public TestFrame () {
super();
setLayout(null);
setSize(188, 116);
UserIdTextField.setBounds(75, 33, 87, 27);
this.add(UserIdTextField);
PasswordTextField.setEchoChar('*');
PasswordTextField.setBounds(75, 71, 87, 27);
this.add(PasswordTextField);
UserIdLabel.setBounds(7, 33, 59, 23);
this.add(UserIdLabel);
PasswordLabel.setBounds(7, 71, 65, 30);
this.add(PasswordLabel);
this.addWindowListener(this);
}
public static void main(java.lang.String[] args) {
//TestFrame aTestFrame = new sandbox.focusbug.TestFrame ();
TestFrame aTestFrame = new TestFrame ();
aTestFrame.setVisible(true);
}
public void windowActivated(java.awt.event.WindowEvent e) {
}
public void windowClosed(java.awt.event.WindowEvent e) {
}
public void windowClosing(java.awt.event.WindowEvent e) {
this.dispose();
System.exit(0);
}
public void windowDeactivated(java.awt.event.WindowEvent e) {
}
public void windowDeiconified(java.awt.event.WindowEvent e) {
}
public void windowIconified(java.awt.event.WindowEvent e) {
}
public void windowOpened(java.awt.event.WindowEvent e) {
UserIdTextField.setText(System.getProperty("user.name"));
if (UserIdTextField.getText().trim().length() > 0)
PasswordTextField.requestFocus();
else
UserIdTextField.requestFocus();
}
}
(Review ID: 39802)
======================================================================
- duplicates
-
JDK-4176602 Request Focus Fails with Consecutive Dialogs
- Closed
- relates to
-
JDK-4065528 requestFocus() does not work with modal Dialog...
- Closed
-
JDK-4173790 1.1.7: Focus Problems with Consecutive Modal JDialogs on win32
- Closed