United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6893325 JComboBox and dragging to an item outside the bounds of the containing JFrame is not selecting that
JDK-6893325 : JComboBox and dragging to an item outside the bounds of the containing JFrame is not selecting that

Details
Type:
Bug
Submit Date:
2009-10-20
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2010-06-14
Component:
client-libs
OS:
solaris_10
Sub-Component:
java.awt
CPU:
sparc
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u16
Fixed Versions:
6u20-rev (b07)

Related Reports
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
The  problem is only that clicking and holding on the JComboBox and dragging to an item outside the bounds of the containing JFrame is not selecting that item that was highlighted when the mouse was released. No other windows/frames/etc. are involved in reproducing the bug.

This problem is on Solaris and CDE/Java Desktop on XWindows, on both the x86 and SPARC 

Reproducable test case 

For a JComboBox, if you click and hold and then release the mouse button on an item that is significantly outside the bounds of the JFrame that the JComboBox was contained in, it will not select that item and a popup menu cancelled event is fired. If you click the combo box and release, and then click the same item as before, it will select that item correctly. If you click and hold and then release the mouse button on an item that is within the confines of the Jframe that contains the JComboBox, then that item WILL be selected correctly.

This was verified to have worked correctly in Java 5, and appears to be a new problem for Java 6.

Reproducable test case
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;


public class ComboBoxBug 
{
    public static final void main(String[] args) {
        JFrame frame = new JFrame("Combo Box Bug");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setLayout(new FlowLayout());

        final JComboBox comboBox = new JComboBox(new Object[] {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"});

        comboBox.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.err.println("Action performed!");
                }
            });

        comboBox.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent e) {
                    System.err.println("Item state changed!");
                }
            });

        comboBox.addPopupMenuListener(new PopupMenuListener() {
                public void popupMenuCanceled(PopupMenuEvent e) {
                    System.err.println("Popup menu cancelled!");
                }
                public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                    System.err.println("Popup menu will become invisible!");

                }
                public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                    System.err.println("Popup menu will become visible!");
                }
            });

        frame.getContentPane().add(comboBox);
        frame.pack();
        frame.setVisible(true);
    }

                                    

Comments
EVALUATION

please see the parent CR
                                     
2010-02-08



Hardware and Software, Engineered to Work Together