I have a problem with a JDialog on top of a full screen JFrame, namely the JDialog kind of disappears when displayed (it bleeds through). I use JRE 1.6.0_03 on Windows. This does not happen under the same version on Linux. I'm attaching the code below.
Test.java:
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class Test extends JFrame {
public Test() {
final Test frame = this;
setDefaultCloseOperation(EXIT_ON_CLOSE);
JButton button = new JButton("Open dialog");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
new TestDialog(frame);
}
});
add(button);
if (!isDisplayable()) {
setUndecorated(true);
}
pack();
setVisible(true);
}
private static void createAndShowGui() {
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
gd.setFullScreenWindow(new Test());
}
public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGui();
}
});
}
}
And
TestDialog.java:
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class TestDialog extends JDialog {
public TestDialog(JFrame frame) {
super(frame);
add(new JTextField("test"));
setModal(true);
pack();
setVisible(true);
}
}
Any ideas why this is happening and how can I solve it? Thanks.