JDK-7145818 : [macosx] dialogs not showing when JFrame is in full screen mode
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2012-02-15
  • Updated: 2012-05-03
  • Resolved: 2012-03-30
Related Reports
Relates :  

When a JFrame is in full screen mode any opened dialog window has keyboard input focus but isn't showing on screen. See the sample code below:

package test;

import java.awt.Dimension;
 import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsDevice;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import javax.swing.AbstractAction;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.KeyStroke;

@author lion
 public class NewJFrame extends javax.swing.JFrame {

Creates new form NewJFrame
 public NewJFrame() { initComponents(); }

This method is called from within the constructor to initialize the form.
WARNING: Do NOT modify this code. The content of this method is always
regenerated by the Form Editor.
 // <editor-fold defaultstate="collapsed" desc="Generated Code">
 private void initComponents() {

 jButton1 = new javax.swing.JButton();
 jCheckBox1 = new javax.swing.JCheckBox();


 jButton1.setText("Show dialog");
 jButton1.addActionListener(new java.awt.event.ActionListener() {
 public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); }

 jCheckBox1.setText("Full Screen");
 jCheckBox1.addItemListener(new java.awt.event.ItemListener() {
 public void itemStateChanged(java.awt.event.ItemEvent evt) { toggleFullscreen(evt); }

 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
 .addContainerGap(274, Short.MAX_VALUE))
 .addContainerGap(236, Short.MAX_VALUE))

 }// </editor-fold>

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
 final JDialog dlg = new JDialog(this, true);
 dlg.setSize(new Dimension(200, 200));
 KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "quit");
 dlg.getRootPane().getActionMap().put("quit", new AbstractAction() {

 public void actionPerformed(ActionEvent ae) { dlg.dispose(); }


 private void toggleFullscreen(java.awt.event.ItemEvent evt) {
 boolean isFullScreenMode = jCheckBox1.isSelected();
 GraphicsDevice device = null;
 GraphicsConfiguration conf = getGraphicsConfiguration();
 if( null != conf ) { device = conf.getDevice(); }

 if( null != device && device.isFullScreenSupported()) { device.setFullScreenWindow( isFullScreenMode ? this : null ); }

@param args the command line arguments
 public static void main(String args[]) {
 java.awt.EventQueue.invokeLater(new Runnable() {

 public void run() { new NewJFrame().setVisible(true); }
 // Variables declaration - do not modify
 private javax.swing.JButton jButton1;
 private javax.swing.JCheckBox jCheckBox1;
 // End of variables declaration

EVALUATION Unfortunately, using the new OS X 10.7 API to enter the full screen (NSWindow -toggleFullScreen: ) is unfeasible. This API doesn't allow one to control the screen on which the full screen mode must be entered. Java API for entering a full screen belongs to the GraphicsDevice class and as such requires the presense of such control. Therefore we can't apply this solution. The current apporach (NSView -enterFullScreen:) doesn't allow other windows to appear above a full screen window. Please refer to the sepcification of GraphicsDevice.setFullScreenWindow() which states: ***************************************************** Windows cannot overlap the full-screen window. All other application windows will always appear beneath the full-screen window in the Z-order. ***************************************************** The test creates a dialog which is another application window, and expects the dialog to appear above the full screen window. This contradicts the specificationof the full screen mode as provided by AWT. Thus we consider this issue being not a defect in Java.

EVALUATION http://cr.openjdk.java.net/~anthony/x-21-popupInFullscreen-7145818.0/

EVALUATION This is most probably an issue with the window level assigned to dialogs. A full screen window obviously is at some kind of "always on top" state, causing the dialogs to be invisible.