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

setAutoscrolls(true) eats mouse events when it shouldn't

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      When the setAutoScrolls(true) method is called, events generated inside a component are not sent to the parent component when there are no listeners present.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run test case, click inside red box.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      should print 'mouse pressed in outer panel'
      ACTUAL -
      doesnt print anything

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class MouseTest extends JFrame{
      public MouseTest() {
      super("PanelList test");
      setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      setSize(500, 500);

      JComponent outerPanel = new JPanel();
      JComponent innerPanel = new JPanel();

      outerPanel.setPreferredSize(new Dimension(400,400));
      innerPanel.setPreferredSize(new Dimension(300,300));

      outerPanel.setBackground(Color.GREEN);
      innerPanel.setBackground(Color.RED);

      innerPanel.setAutoscrolls(true);

      outerPanel.add(innerPanel);
      outerPanel.addMouseListener(new MouseAdapter() {
      public void mousePressed(MouseEvent e) {
      System.out.println("mouse pressed in outer panel");
      }
      });

      add(outerPanel);
      setVisible(true);
      }
      public static void main(String[] args) {
      new MouseTest();
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      adding a mouse listener to the inner panel, refiring events to the outer panel

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: