-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6
-
Fix Understood
-
x86
-
windows_xp
This is reproducible starting jdk6 on Windows platforms
Run the below testcase. It shows a Window with a button in it. On clicking the button, it shows a modal Dialog. On clicking a button on the modal dialog, a Frame is shown. Since the modal dialog is visible, Frame will be blocked. On clicking a 'Close' button on modal dialog, it closes. Now, even though there's a Frame visible, it doesn't get focus.
import java.awt.*;
import java.awt.event.*;
public class FocusTest {
private static Dialog d;
private static Frame f;
public static void main(String[] args) {
f = new Frame();
f.setLayout(new FlowLayout());
f.add(new Button("Click Me"));
f.setSize(150, 150);
f.setLocation(200, 200);
d = new Dialog(new Frame());
d.setLayout(new FlowLayout());
Button db = new Button("Open Frame");
db.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
f.setVisible(true);
}
});
d.add(db);
Button dClose = new Button("Close");
dClose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
d.dispose();
}
});
d.add(dClose);
d.setModal(true);
d.setSize(150, 150);
d.setLocation(0, 200);
Window w = new Window(new Frame());
w.setSize(150, 150);
Button wb = new Button("Open Dialog");
wb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
d.setVisible(true);
}
});
w.setLayout(new FlowLayout());
w.add(wb);
w.setVisible(true);
}
}
Run the below testcase. It shows a Window with a button in it. On clicking the button, it shows a modal Dialog. On clicking a button on the modal dialog, a Frame is shown. Since the modal dialog is visible, Frame will be blocked. On clicking a 'Close' button on modal dialog, it closes. Now, even though there's a Frame visible, it doesn't get focus.
import java.awt.*;
import java.awt.event.*;
public class FocusTest {
private static Dialog d;
private static Frame f;
public static void main(String[] args) {
f = new Frame();
f.setLayout(new FlowLayout());
f.add(new Button("Click Me"));
f.setSize(150, 150);
f.setLocation(200, 200);
d = new Dialog(new Frame());
d.setLayout(new FlowLayout());
Button db = new Button("Open Frame");
db.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
f.setVisible(true);
}
});
d.add(db);
Button dClose = new Button("Close");
dClose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
d.dispose();
}
});
d.add(dClose);
d.setModal(true);
d.setSize(150, 150);
d.setLocation(0, 200);
Window w = new Window(new Frame());
w.setSize(150, 150);
Button wb = new Button("Open Dialog");
wb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
d.setVisible(true);
}
});
w.setLayout(new FlowLayout());
w.add(wb);
w.setVisible(true);
}
}
- relates to
-
JDK-8049339 [solaris] Focus transfer does not happen when closing a dialog.
-
- Open
-