JDK-6325737 : Extended Modifiers on Mouse Events are wrong
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2005-09-19
  • Updated: 2014-03-29
  • Resolved: 2014-03-29
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.
JDK 8
8-poolResolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
J2SE Version (please include all output from java -version flag):
 java version "1.6.0-ea"
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b47)
  Java HotSpot(TM) Client VM (build 1.6.0-ea-b47, mixed mode, sharing)

Does this problem occur on J2SE 1.4.x or 5.0.x ?  Yes / No (pick one)
  Yes

Operating System Configuration Information (be specific):
  Microsoft Windows 2000 [Version 5.00.2195]

Hardware Configuration Information (be specific):
  Pentium 4

Bug Description:
 Extended Modifiers on Mouse Events are wrong

Following the steps produces the following Mouse Events:
java.awt.event.MouseEvent[MOUSE_ENTERED,(450,343),button=0,clickCount=0] 
on Test$2[...]
java.awt.event.MouseEvent[MOUSE_PRESSED,(329,251),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] 
on Test$2[...]
java.awt.event.MouseEvent[MOUSE_RELEASED,(329,251),button=1,modifiers=Button1,clickCount=1] 
on Test$2[...]
java.awt.event.MouseEvent[MOUSE_EXITED,(329,251),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] 
on Test$2[...]
java.awt.event.MouseEvent[MOUSE_ENTERED,(329,251),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] 
on null.glassPane

The extended modifiers of the last 2 mouse events (after the Mouse 
Button was Released) claim that the Button1 is still down.
Either these 2 events should come before the MOUSE_RELEASED event, or 
the extended modifiers should not say that the Button1 is down, either 
way something is wrong here.

Steps to Reproduce (be specific):
1) Run the code below
2) Press the Button

import java.awt.event.*;
import static java.lang.System.*;
import static javax.swing.JFrame.*;
import javax.swing.*;

public class Test {
  public static void main(String[] args) {
    final JFrame frame = new JFrame();
    frame.add(new JButton(new AbstractAction("Test") {
      public void actionPerformed(ActionEvent anEvent) {
        frame.getGlassPane().setVisible(true);
      }
    }) {
      public void processMouseEvent(MouseEvent anEvent) {
        out.println(anEvent);
        super.processMouseEvent(anEvent);
      }
    });
    frame.getGlassPane().addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent anEvent) {
        out.println(anEvent);
      }

      public void mousePressed(MouseEvent anEvent) {
        out.println(anEvent);
      }

      public void mouseReleased(MouseEvent anEvent) {
        out.println(anEvent);
      }

      public void mouseEntered(MouseEvent anEvent) {
        out.println(anEvent);
      }

      public void mouseExited(MouseEvent anEvent) {
        out.println(anEvent);
      }
    });
    frame.setSize(500, 500);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
}

Comments
EVALUATION The root cause of the bug is that the enter|exit events are generated as result of any mouse event including mouse click events (the trackMouseEnterExit method of the Lightweight dipatcher class generates these enter|exit events). Therefore, the mouse|enter events have the same modifiers as the click event has. There should be more reliable way to trigger these events that come as a result of changing visibility of the component. This functionality could possibly be implemented on 4420110 request. I leave this issue open for tracking purpose.
27-10-2005

EVALUATION The problem is reproducible on linux as well.
27-09-2005

EVALUATION Looks like it is a regression related to RealSunc implementation. It could be fixed by 6317481.
19-09-2005