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 :  
Description
http://java.net/jira/browse/MACOSX_PORT-791

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.
 */
 @SuppressWarnings("unchecked")
 // <editor-fold defaultstate="collapsed" desc="Generated Code">
 private void initComponents() {

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

 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

 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());
 getContentPane().setLayout(layout);
 layout.setHorizontalGroup(
 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
 .add(layout.createSequentialGroup()
 .addContainerGap()
 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
 .add(jButton1)
 .add(jCheckBox1))
 .addContainerGap(274, Short.MAX_VALUE))
 );
 layout.setVerticalGroup(
 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
 .add(layout.createSequentialGroup()
 .addContainerGap()
 .add(jCheckBox1)
 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
 .add(jButton1)
 .addContainerGap(236, Short.MAX_VALUE))
 );

 pack();
 }// </editor-fold>

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

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

 });
 dlg.setVisible(true);
 }

 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
 }

Comments
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.
30-03-2012

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

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.
15-02-2012