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
}