JDK-6362692 : grabbed frame misses MouseReleased event outside the toplevel
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: linux
  • CPU: x86
  • Submitted: 2005-12-13
  • Updated: 2011-02-16
  • Resolved: 2010-11-16
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Linux dhola.pna.cwi.nl 2.6.13-1.1526_FC4 #1 Wed Sep 28 19:15:10 EDT 2005 i686 athlon i386 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
When a JComboBox is placed in a modal JDialog, it may not be possible to select an item with the mouse (it is possible to do it with the keyboard arrows).
This will happen if the item-list does not fit in the dialog frame. It only occurs under Linux.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
very simple. see source code.


REPRODUCIBILITY :
This bug can be reproduced always.

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

public class ComboBug extends JFrame
{
   public ComboBug()
   {
      super("ComboBug");
      setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      Container cpane = getContentPane();

      cpane.setLayout( new BorderLayout() );
      cpane.add( new ComboPanel() );

      pack();
      setLocationRelativeTo(null);
      setVisible(true);
   }

   public static void main( String[] args )
   {
      ComboBug mf = new ComboBug();
   }
}

class ComboPanel extends JPanel implements ActionListener
{
   ComboPanel()
   {
      JButton demo = new JButton("show bug ( if Linux )");
      demo.addActionListener(this);
      add( demo );
   }

   public void actionPerformed( ActionEvent e )
   {
      ComboDialog dial = new ComboDialog();
      dial.activate();
   }
}

class ComboDialog extends JDialog
   implements ActionListener
{
   JComboBox combo;

   ComboDialog()
   {
      super( (JFrame)null, true );
      Container cpane = getContentPane();

      combo = new JComboBox
	 ( new String[] { "one", "two", "exit" } );

      combo.addActionListener(this);

      cpane.setLayout( new BorderLayout() );
      cpane.add( combo, BorderLayout.CENTER );
      cpane.add(
		new JLabel
		(" can't select item from this JComboBox with mouse  "),
		BorderLayout.WEST );
      pack();
   }

   void activate()
   {
      setLocationRelativeTo(null);
      combo.setSelectedIndex(0);
      setVisible(true);
   }

   public void actionPerformed( ActionEvent e)
   {
      System.err.println("selected index: " + combo.getSelectedIndex() );
      if ( combo.getSelectedIndex() == 2 ) setVisible(false);
   }
}
---------- END SOURCE ----------

Comments
EVALUATION we do not send mouse release if we press mouse in frame, grab input, drag mouse out of the frame's bounds and release button there :(
07-07-2006

EVALUATION I rewrote the test on pure AWT. Grabbed frame receives MouseReleased event if only mouse positioned in that frame. Though sometimes it receives MouseReleased when mouse is outside the frame. On Windows it recieves Released event always. MToolkit is also affected by this defect. import java.awt.*; import java.awt.event.*; import sun.awt.*; public class MissedReleaseOnPopup extends Frame implements MouseListener{ static Frame frame; public MissedReleaseOnPopup() { super("A frame"); } public static void main(String[] args) { MissedReleaseOnPopup f = new MissedReleaseOnPopup(); MissedReleaseOnPopup.frame = f; f.addMouseListener(f); f.setVisible(true); } public void mouseReleased(MouseEvent me){ System.out.println("release"); ((SunToolkit)Toolkit.getDefaultToolkit()).ungrab(this); } public void mousePressed(MouseEvent me){ System.out.println("press"); ((SunToolkit)Toolkit.getDefaultToolkit()).grab(this); } public void mouseClicked(MouseEvent me){ System.out.println("click"); ((SunToolkit)Toolkit.getDefaultToolkit()).ungrab(this); } public void mouseEntered(MouseEvent me){ System.out.println("enter"); } public void mouseExited(MouseEvent me){ System.out.println("exit"); } }
05-07-2006

EVALUATION BasicComboPopup.Handler doesn't hear MouseReleased sometimes. It's okay with the near items but far items doens't generate MouseReleased events. I'm writing an AWT test that opens a Window on MousePress and listen for events there. But seem that Window receives all relevant events regardless of the distance between start and finish of the drag.
05-07-2006

EVALUATION The problem I observe doens't look the same as submitter says. I've asked him to clarify this point. Anyway we should evaluate this too. I'm able to reproduce it both on KDE and Gnome.
05-07-2006

EVALUATION the bug also reproducible without modality in the test.
03-07-2006

EVALUATION I'm observing that the items are always correctly gets selected with mouse click over them but not when I drag a mouse from the ComboBox to the item. I have an impression that first two items are working fine but starting from the third one them doens't recieve ActionEvent. If I position the Dialog just above the bottom of my screen (so dropdown list would appear above the Dialog) them I'm unable to select any item from the list. And yes, it reacts on keyboard well. I'm using KDE and GNOME both with JDK6.0. But I'm not experiencing problem with JDK1.5.0 and it looks like a thread condition somewhere in the JDK.
30-06-2006

EVALUATION This is Linux only. Re-assigning to AWT.
29-06-2006