Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8013547

[macosx] JComboBox Broken in Full Screen MacOS X

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version " 1.7.0_09 "
      Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin machinename.com 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      JComboboxes do not allow you to change the selection via the mouse like other comboboxes in OS X. When you attempt to make a selection via a click on the combobox, the combobox cancels instead of making the selection.

      Under a debugger, an NSFullScreenWindow steals focus away from the AWTWindow and forces the JCombobox to cancel. The JCombobox (and AWT) never get a chance to handle the click.

      REGRESSION. Last worked in version 6u31

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Left Mouse Down and Up on a combobox (Note that the combobox stays open)
      2) Click on a selection

      ACTUAL: The combobox dismisses and cancels
      EXPECTED: The combobox dismisses and selects the item

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      EXPECTED: The combobox dismisses and selects the item
      ACTUAL -
      ACTUAL: The combobox dismisses and cancels

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;

      import javax.swing.*;
      import javax.swing.UIManager.LookAndFeelInfo;


      /** @see http://stackoverflow.com/questions/7456227 */
      public class Sandbox extends JPanel {

      public static void main(String args[])
      {
      SwingUtilities.invokeLater(new Runnable()
      {
      @Override
      public void run()
      {
      try
      {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
          {
              if ( " Nimbus " .equals(info.getName()))
              {
      UIManager.setLookAndFeel(info.getClassName());
      break;
              }
          }
      }
      catch (Exception e)
      {
      }
      final JFrame frame = new JFrame( " FullScreenTest " );
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();


      JPanel content = new JPanel(new BorderLayout());
      final JLabel label = new JLabel( " Selected Item " );
      final JComboBox comboBox = new JComboBox();
          comboBox.addItem( " Item A " );
          comboBox.addItem( " Item B " );
          comboBox.addItem( " Item C " );
          comboBox.setSize(100, 15);
          comboBox.addActionListener(new ActionListener()
      {
      @Override
      public void actionPerformed(ActionEvent e)
      {
      label.setText((String)comboBox.getItemAt(comboBox.getSelectedIndex()));
      }
      });
          
          JButton close = new JButton( " Close " );
      close.addActionListener(new ActionListener()
      {
      @Override
      public void actionPerformed(ActionEvent e)
      {
      WindowEvent windowClosing = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
      frame.dispatchEvent(windowClosing);
      }
      });
          
      JPanel comboBoxContainer = new JPanel();
      comboBoxContainer.add(comboBox);

      content.add(label, BorderLayout.NORTH);
      content.add(comboBoxContainer, BorderLayout.CENTER);
      content.add(close, BorderLayout.SOUTH);

      frame.setContentPane(content);
      frame.setUndecorated(true);
      frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
      frame.pack();

      device.setFullScreenWindow(frame);
      frame.setVisible(true);
      }
      });
      }
      }
      ---------- END SOURCE ----------

            serb Sergey Bylokhov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: