Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4492739
Votes 0
Synopsis KeyEvent.getKeyModifiersText(int) unclear
Category guides:none
Reported Against merlin , tiger-beta
Release Fixed 1.5(tiger)
State 10-Fix Delivered, Verified, bug
Priority: 4-Low
Related Bugs
Submit Date 16-AUG-2001
Description
.


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


======================================================================
Work Around
N/A
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.  

  xxxxx@xxxxx   2002-08-28


Changes reviewed by Eric.  Approved by CCC.  Fixed for tiger.
  xxxxx@xxxxx   2003-08-29
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang