JDK-4492739 : KeyEvent.getKeyModifiersText(int) unclear
  • 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: 2001-08-16
  • 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 Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Description
Name: sdR10048			Date: 08/16/2001


Javadoc for 
public static String getKeyModifiersText(int modifiers) should declare
the the exactly range of input parameters and the output
values. Currently (in jdk1.4beta-b75) this method for ints:
 KeyEvent.BUTTON1_MASK
 KeyEvent.BUTTON2_MASK
 KeyEvent.BUTTON3_MASK
returns not quite predictable strings. See demo:
-----
import java.awt.*;
import java.awt.event.*;

public class Test {
    public static void main(String[] args) {
        System.out.println( "KeyEvent.ALT_MASK:      " + KeyEvent.getKeyModifiersText(KeyEvent.ALT_MASK) );
        System.out.println( "KeyEvent.META_MASK:     " + KeyEvent.getKeyModifiersText(KeyEvent.META_MASK) );
        System.out.println( "KeyEvent.CTRL_MASK:     " + KeyEvent.getKeyModifiersText(KeyEvent.CTRL_MASK) );
        System.out.println( "KeyEvent.SHIFT_MASK:    " + KeyEvent.getKeyModifiersText(KeyEvent.SHIFT_MASK) );
        System.out.println( "KeyEvent.ALT_GRAPH_MASK:" + KeyEvent.getKeyModifiersText(KeyEvent.ALT_GRAPH_MASK) );
        System.out.println( "KeyEvent.BUTTON1_MASK:  " + KeyEvent.getKeyModifiersText(KeyEvent.BUTTON1_MASK) );
        System.out.println( "KeyEvent.BUTTON2_MASK:  " + KeyEvent.getKeyModifiersText(KeyEvent.BUTTON2_MASK) );
        System.out.println( "KeyEvent.BUTTON3_MASK:  " + KeyEvent.getKeyModifiersText(KeyEvent.BUTTON3_MASK) );
    }
}
-----
output:
KeyEvent.ALT_MASK:      Alt
KeyEvent.META_MASK:     Meta
KeyEvent.CTRL_MASK:     Ctrl
KeyEvent.SHIFT_MASK:    Shift
KeyEvent.ALT_GRAPH_MASK:Alt Graph
KeyEvent.BUTTON1_MASK:  Button1
KeyEvent.BUTTON2_MASK:  Alt
KeyEvent.BUTTON3_MASK:  Meta

Javadoc for this method says:
public static String getKeyModifiersText(int modifiers)

    Returns a String describing the modifier key(s), such as "Shift",
    or "Ctrl+Shift". These strings can be localized by changing the
    awt.properties file. 

    Returns:
        string a text description of the combination of modifier keys
        that were held down during the event


======================================================================

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

PUBLIC COMMENTS .
17-09-2004

EVALUATION As the submitter discovered, InputEvent.BUTTON2_MASK has the same value as InputEvent.ALT_MASK and InputEvent.BUTTON3_MASK has the same value as InputEvent.META_MASK. Note: a similar problem may exist for MouseEvent.getMouseModifiersText(int). Perhaps the docs for KeyEvent, MouseEvent, and InputEvent should mention this. Also, KeyEvent.getKeyModifiersText and MouseEvent.getMouseModifiersText(int) should probably reference InputEvent.getModifiersExText(int), which does not have this ambiguity. ###@###.### 2002-08-28 Changes reviewed by Eric. Approved by CCC. Fixed for tiger. ###@###.### 2003-08-29
28-08-2002