JDK-4897333 : XP L&F: JComboBox has wrong rollover effect under Windows XP LookAndFeel
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2003-07-28
  • Updated: 2004-10-13
  • Resolved: 2004-09-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u3Fixed 6 betaFixed
Description

Name: rmT116609			Date: 07/28/2003


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
Native windows ComboBox control has rollover effect (it's should be highlighted when mouse pointer is over it). Swing JComboBox has different rollover effect. JComboBox is highlighted only if mouse pointer is over drop down button. But it should be highlighted when the mouse is inside its bounds.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Switch to Windows XP style and Default(blue) color scheme
2. Compile and run attached sample application
3. When frame appears move mouse to the center combobox. Be sure the mouse is not over the drop down button.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JComboBox should be highlighted
ACTUAL -
There is no any highlighting effect

REPRODUCIBILITY :
This bug can be reproduced always.

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

/**
 * @author Vladimir Kondratyev
 */
public class test {
  public static void main(String[] args) throws IllegalAccessException, ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    JFrame frame = new JFrame("Test");
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new BorderLayout());
    frame.addWindowListener(
      new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          System.exit(0);
        }
      }
    );

    JComboBox jComboBox = new JComboBox(new Object[]{"one", "two", "three"});
    contentPane.add(jComboBox, BorderLayout.CENTER);

    frame.pack();
    frame.show();
  }
}
---------- END SOURCE ----------
(Incident Review ID: 192646) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon mustang FIXED IN: mustang INTEGRATED IN: mustang
14-09-2004

EVALUATION Name: keR10081 Date: 09/10/2003 We need to behave like a native application. ###@###.### ====================================================================== Name: keR10081 Date: 10/10/2003 We need to apply the suggested fix to achieve native behaviour. ###@###.### ======================================================================
14-09-2004

SUGGESTED FIX Name: keR10081 Date: 10/10/2003 ------- WindowsComboBoxUI.java ------- *** /tmp/sccs.8qaWQK Fri Oct 10 17:13:40 2003 --- WindowsComboBoxUI.java Fri Oct 10 17:10:39 2003 *************** *** 31,36 **** --- 31,38 ---- public class WindowsComboBoxUI extends BasicComboBoxUI { + MouseListener rolloverListener; + public static ComponentUI createUI(JComponent c) { return new WindowsComboBoxUI(); } *************** *** 38,45 **** --- 40,57 ---- public void installUI( JComponent c ) { super.installUI( c ); comboBox.setRequestFocusEnabled( true ); + if (XPStyle.getXP() != null && arrowButton != null) { + rolloverListener = new RolloverListener(); + comboBox.addMouseListener(rolloverListener); + } } + public void uninstallUI(JComponent c ) { + if (XPStyle.getXP() != null) { + comboBox.removeMouseListener(rolloverListener); + } + super.uninstallUI( c ); + } /** * Creates a layout manager for managing the components which make up the * combo box. *************** *** 147,150 **** --- 159,174 ---- } } } + class RolloverListener extends MouseAdapter { + public void mouseEntered(MouseEvent e) { + ButtonModel m = null; + if (arrowButton != null) m = arrowButton.getModel(); + if (m != null ) m.setRollover(true); + } + public void mouseExited(MouseEvent e) { + ButtonModel m = null; + if (arrowButton != null) m = arrowButton.getModel(); + if (m != null ) m.setRollover(false); + } + } } ======================================================================
14-09-2004