-
Bug
-
Resolution: Fixed
-
P4
-
1.0.2, 1.1.2, 1.1.4, 1.1.6, 1.1.7, 1.2.0
-
1.1.8
-
x86
-
windows_nt
-
Verified
When the example below is compiled and run with JDK 1.1.7E on win32, the text field that requests the focus after the second dialog is dismissed fails to
obtain it. This happens only on win32.
-------------------------------- DoubleFocusAwt.java ---------------------------
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class DoubleFocusAwt extends Frame {
public DoubleFocusAwt() {
setSize(400, 300);
setLayout(new FlowLayout());
tf1.setColumns(10);
tf2.setColumns(16);
add(tf1);
add(tf2);
tf1.requestFocus();
add(targetButton);
targetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
tf1.setText("");
tf2.setText("");
doDlgSequence();
}
});
}
public static void main(String[] args) {
DoubleFocusAwt bt = new DoubleFocusAwt();
bt.setVisible(true);
dlg1 = new Dlg(bt, "This is dialog 1");
}
public void doDlgSequence() {
showDlg1();
showDlg2();
}
public void showDlg1() {
dlg1.setVisible(true);
}
public void showDlg2() {
Dlg dlg2 = new Dlg(new Frame(), "This is dialog 2");
dlg2.setVisible(true);
tf1.requestFocus();
}
Button targetButton = new Button("Click Here");
static Dlg dlg1 ;
static Frame frame;
TextField tf1 = new TextField("Tab to next");
TextField tf2 = new TextField("Tab to next");
}
class Dlg extends Dialog {
public Dlg(Frame frame, String str) {
super(frame);
setSize(200, 200);
setLayout(new FlowLayout());
add(new Label(str));
add(button);
setModal(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
setVisible(false);
}
});
}
Button button = new Button("OK");
}
obtain it. This happens only on win32.
-------------------------------- DoubleFocusAwt.java ---------------------------
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class DoubleFocusAwt extends Frame {
public DoubleFocusAwt() {
setSize(400, 300);
setLayout(new FlowLayout());
tf1.setColumns(10);
tf2.setColumns(16);
add(tf1);
add(tf2);
tf1.requestFocus();
add(targetButton);
targetButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
tf1.setText("");
tf2.setText("");
doDlgSequence();
}
});
}
public static void main(String[] args) {
DoubleFocusAwt bt = new DoubleFocusAwt();
bt.setVisible(true);
dlg1 = new Dlg(bt, "This is dialog 1");
}
public void doDlgSequence() {
showDlg1();
showDlg2();
}
public void showDlg1() {
dlg1.setVisible(true);
}
public void showDlg2() {
Dlg dlg2 = new Dlg(new Frame(), "This is dialog 2");
dlg2.setVisible(true);
tf1.requestFocus();
}
Button targetButton = new Button("Click Here");
static Dlg dlg1 ;
static Frame frame;
TextField tf1 = new TextField("Tab to next");
TextField tf2 = new TextField("Tab to next");
}
class Dlg extends Dialog {
public Dlg(Frame frame, String str) {
super(frame);
setSize(200, 200);
setLayout(new FlowLayout());
add(new Label(str));
add(button);
setModal(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
setVisible(false);
}
});
}
Button button = new Button("OK");
}
- duplicates
-
JDK-4173790 1.1.7: Focus Problems with Consecutive Modal JDialogs on win32
- Closed
-
JDK-4178187 requestFocus not working in 1.1.7
- Closed
-
JDK-4237857 Input focus on JTextField has wrong behavior.
- Closed
- relates to
-
JDK-4208500 Focus Freezes on Win32 after Dialog is Dismissed
- Closed