JDK-4761790 : java.awt.event.MouseEvent: ambiguous Ctor
  • Type: Bug
  • Component: docs
  • Sub-Component: guides
  • Affected Version: 1.4.0,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_7
  • CPU: generic,sparc
  • Submitted: 2002-10-11
  • Updated: 2017-05-16
  • Resolved: 2004-09-15
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 Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Description
Name: sdR10048			Date: 10/11/2002


JDK1.4 doc for
public java.awt.event.MouseEvent(Component source, int id,
                                 long when, int modifiers,
                                 int x, int y, int clickCount,
                                 boolean popupTrigger, int button)
says:

> Constructs a MouseEvent object with the specified source component, ty
> pe, modifiers, coordinates, and click count.
>
> Note that passing in an invalid id results in unspecified behavior.
>
> Parameters:
> source - the Component that originated the event
> id - the integer that identifies the event
> when - a long int that gives the time the event occurred
> modifiers - the modifier keys down during event (e.g. shift, ctrl,
> alt, meta) Either extended _DOWN_MASK or old _MASK modifiers should be
> used, but both models should not be mixed in one event. Use of the
> extended modifiers is preferred.
> x - the horizontal x coordinate for the mouse location
> y - the vertical y coordinate for the mouse location
> clickCount - the number of mouse clicks associated with event
> popupTrigger - a boolean, true if this event is a trigger for a popup
> menu
> button - which of the mouse buttons has changed state. NOBUTTON,
> BUTTON1, BUTTON2 or BUTTON3.
> Throws:
> IllegalArgumentException - if if an invalid button value is passed in.
It is not clear what if say 'modifiers' == MouseEvent.BUTTON1_MASK and
'button' == MouseEvent.BUTTON2. What getButton() will return.
Currently JDK returns what has been specified by 'modifiers'.
And point # 2: what is the right behavior here if 'modifiers' ==
MouseEvent.BUTTON1_MASK | MouseEvent.BUTTON3_MASK?

See small demo about it:

import java.awt.event.*;
import java.awt.*;

class Test {
    public static void main(String args[]) {
        MouseEvent event =
            new MouseEvent(new Container(),
                           MouseEvent.MOUSE_CLICKED,
                           0,
                           MouseEvent.BUTTON1_MASK,       // button # 1
                           0, 0, 0, true,
                           MouseEvent.BUTTON2);           // button # 2
        System.out.println("button: "+event.getButton()); // button # ?
    }
}

Demo output:

] ~/tmp
] java Test
button: 1

Need for jck test development.
======================================================================
###@###.### 2004-09-15

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b19 VERIFIED IN: 1.5
2004-09-17

PUBLIC COMMENTS .
2004-09-17

EVALUATION Reviewed by Brent. Approved by CCC. Fixed for tiger. ###@###.### 2003-08-18
2003-08-18