United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4492739 : KeyEvent.getKeyModifiersText(int) unclear

Details
Type:
Bug
Submit Date:
2001-08-16
Status:
Closed
Updated Date:
2004-09-15
Project Name:
JDK
Resolved Date:
2004-09-15
Component:
docs
OS:
solaris_7,generic
Sub-Component:
guides
CPU:
sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0,5.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

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
PUBLIC COMMENTS

.
                                     
2004-09-17
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b21

VERIFIED IN:
1.5


                                     
2004-09-17
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
                                     
2002-08-28



Hardware and Software, Engineered to Work Together