-
Bug
-
Resolution: Fixed
-
P3
-
6
FULL PRODUCT VERSION :
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b84)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-beta2-b84, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Red Hat Linux Fedora Core 4: custom 2.6.16 kernel x86_64
Solaris 8
EXTRA RELEVANT SYSTEM CONFIGURATION :
non-xinerama multiple head X-windows system
A DESCRIPTION OF THE PROBLEM :
When using multiple screens within one application, awt gets confused about which window should receive focus when using modal dialogs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile & run the attached program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pressing "Open Dialog" should open a dialog with one button ("Close") on any screen. Pressing "Close" should close the dialog, and allow one to press "Open Dialog" again.
ACTUAL -
Only on the primary screen does the "Close" button close the dialog. On the secondary (I only have 2 screens) screen pressing the "Close" button brings the original JFrame on top of the dialog rather than closing the dialog. As long as "Close" is pressed somewhere within the boundaries of the original JFrame, that JFrame is brought forward (even though it doesn't get focus). If the dialog is moved away from the JFrame and "Close" is pressed, it works properly.
Note that on some window managers it isn't possible to get to the JDialog hiding behind the JFrame when this happens. As a result, the user has an unresposive desktop until the Java process is killed. On Solaris 8 using dtwm, things can get really nasty (even killing the Java app doesn't necessarily put things right).
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class TestCase {
public TestCase() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
if (gs.length<2) {
System.out.println("Not multi-head environment, test not valid!");
System.exit(1);
}
for (int i=0; i<gs.length; i++) {
JFrame frame=new JFrame("Frame "+i,gs[i].getDefaultConfiguration());
JButton button=new JButton("Open Dialog");
button.setMinimumSize(new Dimension(200,100));
button.setPreferredSize(new Dimension(200,100));
button.setSize(new Dimension(200,100));
button.addActionListener(new ButtonActionListener(frame,new TestDialog(frame,"Dialog #"+i,true,gs[i].getDefaultConfiguration())));
frame.getContentPane().add(button);
frame.pack();
frame.show();
}
}
private static class ButtonActionListener implements ActionListener {
JFrame frame;
JDialog dialog;
public ButtonActionListener(JFrame frame,JDialog dialog) {
super();
this.frame=frame;
this.dialog=dialog;
}
public void actionPerformed(ActionEvent e) {
dialog.setLocationRelativeTo(frame);
dialog.show();
}
}
public static class TestDialog extends JDialog {
public TestDialog(Frame owner,String title, boolean modal, GraphicsConfiguration gc) {
super(owner,title,modal,gc);
JButton button=new JButton("Close");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
getContentPane().add(button);
pack();
}
}
public static void main(String args[]) {
new TestCase();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use an older version of the JVM (<1.6)
java version "1.6.0-beta2"
Java(TM) SE Runtime Environment (build 1.6.0-beta2-b84)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-beta2-b84, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Red Hat Linux Fedora Core 4: custom 2.6.16 kernel x86_64
Solaris 8
EXTRA RELEVANT SYSTEM CONFIGURATION :
non-xinerama multiple head X-windows system
A DESCRIPTION OF THE PROBLEM :
When using multiple screens within one application, awt gets confused about which window should receive focus when using modal dialogs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile & run the attached program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pressing "Open Dialog" should open a dialog with one button ("Close") on any screen. Pressing "Close" should close the dialog, and allow one to press "Open Dialog" again.
ACTUAL -
Only on the primary screen does the "Close" button close the dialog. On the secondary (I only have 2 screens) screen pressing the "Close" button brings the original JFrame on top of the dialog rather than closing the dialog. As long as "Close" is pressed somewhere within the boundaries of the original JFrame, that JFrame is brought forward (even though it doesn't get focus). If the dialog is moved away from the JFrame and "Close" is pressed, it works properly.
Note that on some window managers it isn't possible to get to the JDialog hiding behind the JFrame when this happens. As a result, the user has an unresposive desktop until the Java process is killed. On Solaris 8 using dtwm, things can get really nasty (even killing the Java app doesn't necessarily put things right).
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class TestCase {
public TestCase() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
if (gs.length<2) {
System.out.println("Not multi-head environment, test not valid!");
System.exit(1);
}
for (int i=0; i<gs.length; i++) {
JFrame frame=new JFrame("Frame "+i,gs[i].getDefaultConfiguration());
JButton button=new JButton("Open Dialog");
button.setMinimumSize(new Dimension(200,100));
button.setPreferredSize(new Dimension(200,100));
button.setSize(new Dimension(200,100));
button.addActionListener(new ButtonActionListener(frame,new TestDialog(frame,"Dialog #"+i,true,gs[i].getDefaultConfiguration())));
frame.getContentPane().add(button);
frame.pack();
frame.show();
}
}
private static class ButtonActionListener implements ActionListener {
JFrame frame;
JDialog dialog;
public ButtonActionListener(JFrame frame,JDialog dialog) {
super();
this.frame=frame;
this.dialog=dialog;
}
public void actionPerformed(ActionEvent e) {
dialog.setLocationRelativeTo(frame);
dialog.show();
}
}
public static class TestDialog extends JDialog {
public TestDialog(Frame owner,String title, boolean modal, GraphicsConfiguration gc) {
super(owner,title,modal,gc);
JButton button=new JButton("Close");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
getContentPane().add(button);
pack();
}
}
public static void main(String args[]) {
new TestCase();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use an older version of the JVM (<1.6)
- relates to
-
JDK-6563771 Erroneous window closing and complete workstation freeze up
- Closed
-
JDK-6431340 NullPointerException on Dialog hide on dual head system (non-xinerama)
- Resolved