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

JComboBox does not fire any mouse events with Metal L&F

    XMLWordPrintable

    Details

      Description

      Name: agR10216 Date: 10/16/2002


      JComboBox does not fire mouse events with Metal L&F.
      The bug can be reproduced using the build 1.4.2-beta-b02
      with the following test case.

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

      public class JComboBoxMouseEventTest {
          static String[] lfs = { "javax.swing.plaf.metal.MetalLookAndFeel",
                                  "com.sun.java.swing.plaf.motif.MotifLookAndFeel",
                                  "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
                                };

          public static void main(String[] args) throws Exception {
              int i = 0;
              try {
                  i = Integer.parseInt(args[0]);
              } catch (Exception exc) {}
              if (i < 0 || i > 2) {
                  i = 0;
              }
              UIManager.setLookAndFeel(lfs[i]);

              JComboBox choice = new JComboBox();
              choice.addItem("Item 1");
              choice.addItem("Item 2");
              choice.addMouseListener(new MouseAdapter() {
                  public void mouseClicked(MouseEvent e) {
                      System.err.println(e);
                  }
                  public void mousePressed(MouseEvent e) {
                      System.err.println(e);
                  }
                  public void mouseReleased(MouseEvent e) {
                      System.err.println(e);
                  }
                  public void mouseEntered(MouseEvent e) {
                      System.err.println(e);
                  }
                  public void mouseExited(MouseEvent e) {
                      System.err.println(e);
                  }
              });
              choice.addMouseMotionListener(new MouseMotionAdapter() {
                  public void mouseDragged(MouseEvent e) {
                      System.err.println(e);
                  }
                  public void mouseMoved(MouseEvent e) {
                      System.err.println(e);
                  }
              });

              JFrame frame = new JFrame("JComboBoxMouseEventTest");
              frame.getContentPane().setLayout(new FlowLayout());
              frame.getContentPane().add(choice);
              frame.setSize(200, 200);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
          }
      }
      -------------------------------------------------------------------

      Moreover, with Windows L&F if the mouse enters the push-down
      arrow and stops, then the delivered events are like these:

      java.awt.event.MouseEvent[MOUSE_ENTERED,(36,20),button=0,clickCount=0] on javax.
      swing.JComboBox[,70,5,51x21,layout=javax.swing.plaf.basic.BasicComboBoxUI$ComboB
      oxLayoutManager,alignmentX=null,alignmentY=null,border=javax.swing.plaf.basic.Ba
      sicBorders$FieldBorder@17e121c,flags=328,maximumSize=,minimumSize=,preferredSize
      =,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemRe
      minder=Item 1]
      java.awt.event.MouseEvent[MOUSE_MOVED,(36,20),button=0,clickCount=0] on javax.sw
      ing.JComboBox[,70,5,51x21,layout=javax.swing.plaf.basic.BasicComboBoxUI$ComboBox
      LayoutManager,alignmentX=null,alignmentY=null,border=javax.swing.plaf.basic.Basi
      cBorders$FieldBorder@17e121c,flags=328,maximumSize=,minimumSize=,preferredSize=,
      isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemRemi
      nder=Item 1]
      java.awt.event.MouseEvent[MOUSE_MOVED,(36,19),button=0,clickCount=0] on javax.sw
      ing.JComboBox[,70,5,51x21,layout=javax.swing.plaf.basic.BasicComboBoxUI$ComboBox
      LayoutManager,alignmentX=null,alignmentY=null,border=javax.swing.plaf.basic.Basi
      cBorders$FieldBorder@17e121c,flags=328,maximumSize=,minimumSize=,preferredSize=,
      isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemRemi
      nder=Item 1]
      java.awt.event.MouseEvent[MOUSE_EXITED,(36,18),button=0,clickCount=0] on javax.s
      wing.JComboBox[,70,5,51x21,layout=javax.swing.plaf.basic.BasicComboBoxUI$ComboBo
      xLayoutManager,alignmentX=null,alignmentY=null,border=javax.swing.plaf.basic.Bas
      icBorders$FieldBorder@17e121c,flags=328,maximumSize=,minimumSize=,preferredSize=
      ,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemRem
      inder=Item 1]

      The MOUSE_EXITED event is superfluous.

      ###@###.### 2002-10-16
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              shickeysunw Shannon Hickey (Inactive)
              Reporter:
              agerasimsunw Alexander Gerasimov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: