-
Bug
-
Resolution: Unresolved
-
P4
-
5.0
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Server VM (build 1.5.0_10-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux rhodos 2.6.16.27-0.6-smp #1 SMP Wed Dec 13 09:34:50 UTC 2006 i686 i686 i386 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
- german laptop-keyboard (DELL Precision M90)
- openSuSE 10.1
A DESCRIPTION OF THE PROBLEM :
I try to implement an InputMethod for diacritical characters via keyboard shortcuts.
I collect the keystrokes (e.g. ALT+CTRL+...+A) in InputMethod.dispatchEvent(AWTEvent event) an commit the appropriate unicode-Character sequence to the textinput component (e.g. JTextArea).
Every thing works fine, but if I press the button marked whith (ß?\) and (`´) I don't receive neither a KeyEvent.KEY_PRESSED event nor a KeyEvent.KEY_TYPED event but a KeyEvent.KEY_RELEASED event :
KEY_RELEASED (Code: 0, Text: Unknown keyCode: 0x0).
Event: java.awt.event.KeyEvent[KEY_RELEASED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='ß',keyLocation=KEY_LOCATION_UNKNOWN] on javax.swing.JTextArea[,0,0,729x459,
layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,
alignmentX=0.0,
alignmentY=0.0,
...
word=false,wrap=false]
KEY_RELEASED (Code: 0, Text: Unknown keyCode: 0x0).
Event: java.awt.event.KeyEvent[KEY_RELEASED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='´',keyLocation=KEY_LOCATION_UNKNOWN] on javax.swing.JTextArea[,0,0,729x459,
layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,
alignmentX=0.0,
...
word=false,wrap=false]
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- generate an InputMethod-Extension from the demo-code below (class TestInputMethod an class TestInputMethodDescriptor)
- compile and start class IMFFrame
- press ALT+9 and sellect IMF-BUG InputMethod
- press ß and ´ key
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect an "KEY_PRESSED (Code: ..." message to indicate that an KEY_PRESSED event was found
ACTUAL -
no "KEY_PRESSED (Code: ..." => no KEY_PRESSED event was found
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error message
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//##################################################
// Testprogramm (select InputMethod whith ALT+9)
import javax.swing.*;
import java.util.prefs.*;
import java.awt.event.*;
import java.io.*;
public class IMFFrame extends JFrame {
public static void main(String[] args){
IMFFrame i=new IMFFrame();
}
IMFFrame(){
super("IMF Bug?");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// set IM HotKey
Preferences userRoot=Preferences.userRoot();
Preferences userNode=userRoot.node("/java/awt/im/selectionKey");
userNode.putInt("keyCode", KeyEvent.VK_9);
userNode.putInt("modifiers",InputEvent.ALT_DOWN_MASK);
JTextArea ta=new JTextArea();
this.add(ta);
this.pack();
this.setVisible(true);
}
}
//##################################################
import java.awt.AWTException;
public class TestInputMethodDescriptor implements InputMethodDescriptor {
private static Locale[] locale={Locale.GERMAN};
public InputMethod createInputMethod() throws Exception {
return new TestInputMethod();
}
public Locale[] getAvailableLocales() throws AWTException {
return locale;
}
public String getInputMethodDisplayName(Locale inputLang, Locale displayLang) {
return "IMF-BUG";
}
public Image getInputMethodIcon(Locale arg0) {
return null;
}
public boolean hasDynamicLocaleList() {
return false;
}
}
//###################################################
//
// For simplicity, I don't send any text to the textcomponent.
//
// I only print log messages to System.err... to indicate received events.
//
import java.awt.*;
public class TestInputMethod implements InputMethod {
private static Locale[] SUPPORTED_LOCALES={Locale.GERMAN};
private boolean active=false;
private InputMethodContext context;
private Locale currLocale=SUPPORTED_LOCALES[0];
public void activate() {
active=true;
}
public void deactivate(boolean isTemporary) {
active=false;
}
public void dispatchEvent(AWTEvent event) {
if(event instanceof KeyEvent){
KeyEvent keyEvent=(KeyEvent)event;
if(keyEvent.getID()==KeyEvent.KEY_PRESSED){
System.err.println("KEY_PRESSED (Code: "+keyEvent.getKeyCode()+", Text: "+KeyEvent.getKeyText(keyEvent.getKeyCode())+").");
}else if(keyEvent.getID()==KeyEvent.KEY_RELEASED){
System.err.println("KEY_RELEASED (Code: "+keyEvent.getKeyCode()+", Text: "+KeyEvent.getKeyText(keyEvent.getKeyCode())+").");
}else if(keyEvent.getID()==KeyEvent.KEY_TYPED){
System.err.println("KEY_TYPED: Char: >"+keyEvent.getKeyChar()+"<\tCode: >"+keyEvent.getKeyCode()+"<\t Text: >"+KeyEvent.getKeyText(keyEvent.getKeyCode())+"<");
}else{
System.err.println("Unknown (ID="+keyEvent.getID()+")");
}
}
System.out.println("Event: "+event.toString());
System.out.println("------------------------------");
}
public void dispose() {
if(active){
return;
}
}
public void endComposition() {}
public Object getControlObject() {
return null;
}
public Locale getLocale() {
return currLocale;
}
public void hideWindows() {}
public boolean isCompositionEnabled() {
return false;
}
public void notifyClientWindowChange(Rectangle bounds){}
public void reconvert() {}
public void removeNotify() {}
public void setCharacterSubsets(Subset[] subsets) {}
public void setCompositionEnabled(boolean enable) {}
public void setInputMethodContext(InputMethodContext context) {
this.context=context;
}
public boolean setLocale(Locale locale) {
for(int i=0;i<SUPPORTED_LOCALES.length;i++){
if(SUPPORTED_LOCALES[i].equals(locale)){
this.currLocale=locale;
return true;
}
}
return false;
}
}//Ende: public class TestInputMethod implements InputMethod
//###################################################
---------- END SOURCE ----------
java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Server VM (build 1.5.0_10-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux rhodos 2.6.16.27-0.6-smp #1 SMP Wed Dec 13 09:34:50 UTC 2006 i686 i686 i386 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
- german laptop-keyboard (DELL Precision M90)
- openSuSE 10.1
A DESCRIPTION OF THE PROBLEM :
I try to implement an InputMethod for diacritical characters via keyboard shortcuts.
I collect the keystrokes (e.g. ALT+CTRL+...+A) in InputMethod.dispatchEvent(AWTEvent event) an commit the appropriate unicode-Character sequence to the textinput component (e.g. JTextArea).
Every thing works fine, but if I press the button marked whith (ß?\) and (`´) I don't receive neither a KeyEvent.KEY_PRESSED event nor a KeyEvent.KEY_TYPED event but a KeyEvent.KEY_RELEASED event :
KEY_RELEASED (Code: 0, Text: Unknown keyCode: 0x0).
Event: java.awt.event.KeyEvent[KEY_RELEASED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='ß',keyLocation=KEY_LOCATION_UNKNOWN] on javax.swing.JTextArea[,0,0,729x459,
layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,
alignmentX=0.0,
alignmentY=0.0,
...
word=false,wrap=false]
KEY_RELEASED (Code: 0, Text: Unknown keyCode: 0x0).
Event: java.awt.event.KeyEvent[KEY_RELEASED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar='´',keyLocation=KEY_LOCATION_UNKNOWN] on javax.swing.JTextArea[,0,0,729x459,
layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,
alignmentX=0.0,
...
word=false,wrap=false]
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- generate an InputMethod-Extension from the demo-code below (class TestInputMethod an class TestInputMethodDescriptor)
- compile and start class IMFFrame
- press ALT+9 and sellect IMF-BUG InputMethod
- press ß and ´ key
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect an "KEY_PRESSED (Code: ..." message to indicate that an KEY_PRESSED event was found
ACTUAL -
no "KEY_PRESSED (Code: ..." => no KEY_PRESSED event was found
ERROR MESSAGES/STACK TRACES THAT OCCUR :
no error message
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//##################################################
// Testprogramm (select InputMethod whith ALT+9)
import javax.swing.*;
import java.util.prefs.*;
import java.awt.event.*;
import java.io.*;
public class IMFFrame extends JFrame {
public static void main(String[] args){
IMFFrame i=new IMFFrame();
}
IMFFrame(){
super("IMF Bug?");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// set IM HotKey
Preferences userRoot=Preferences.userRoot();
Preferences userNode=userRoot.node("/java/awt/im/selectionKey");
userNode.putInt("keyCode", KeyEvent.VK_9);
userNode.putInt("modifiers",InputEvent.ALT_DOWN_MASK);
JTextArea ta=new JTextArea();
this.add(ta);
this.pack();
this.setVisible(true);
}
}
//##################################################
import java.awt.AWTException;
public class TestInputMethodDescriptor implements InputMethodDescriptor {
private static Locale[] locale={Locale.GERMAN};
public InputMethod createInputMethod() throws Exception {
return new TestInputMethod();
}
public Locale[] getAvailableLocales() throws AWTException {
return locale;
}
public String getInputMethodDisplayName(Locale inputLang, Locale displayLang) {
return "IMF-BUG";
}
public Image getInputMethodIcon(Locale arg0) {
return null;
}
public boolean hasDynamicLocaleList() {
return false;
}
}
//###################################################
//
// For simplicity, I don't send any text to the textcomponent.
//
// I only print log messages to System.err... to indicate received events.
//
import java.awt.*;
public class TestInputMethod implements InputMethod {
private static Locale[] SUPPORTED_LOCALES={Locale.GERMAN};
private boolean active=false;
private InputMethodContext context;
private Locale currLocale=SUPPORTED_LOCALES[0];
public void activate() {
active=true;
}
public void deactivate(boolean isTemporary) {
active=false;
}
public void dispatchEvent(AWTEvent event) {
if(event instanceof KeyEvent){
KeyEvent keyEvent=(KeyEvent)event;
if(keyEvent.getID()==KeyEvent.KEY_PRESSED){
System.err.println("KEY_PRESSED (Code: "+keyEvent.getKeyCode()+", Text: "+KeyEvent.getKeyText(keyEvent.getKeyCode())+").");
}else if(keyEvent.getID()==KeyEvent.KEY_RELEASED){
System.err.println("KEY_RELEASED (Code: "+keyEvent.getKeyCode()+", Text: "+KeyEvent.getKeyText(keyEvent.getKeyCode())+").");
}else if(keyEvent.getID()==KeyEvent.KEY_TYPED){
System.err.println("KEY_TYPED: Char: >"+keyEvent.getKeyChar()+"<\tCode: >"+keyEvent.getKeyCode()+"<\t Text: >"+KeyEvent.getKeyText(keyEvent.getKeyCode())+"<");
}else{
System.err.println("Unknown (ID="+keyEvent.getID()+")");
}
}
System.out.println("Event: "+event.toString());
System.out.println("------------------------------");
}
public void dispose() {
if(active){
return;
}
}
public void endComposition() {}
public Object getControlObject() {
return null;
}
public Locale getLocale() {
return currLocale;
}
public void hideWindows() {}
public boolean isCompositionEnabled() {
return false;
}
public void notifyClientWindowChange(Rectangle bounds){}
public void reconvert() {}
public void removeNotify() {}
public void setCharacterSubsets(Subset[] subsets) {}
public void setCompositionEnabled(boolean enable) {}
public void setInputMethodContext(InputMethodContext context) {
this.context=context;
}
public boolean setLocale(Locale locale) {
for(int i=0;i<SUPPORTED_LOCALES.length;i++){
if(SUPPORTED_LOCALES[i].equals(locale)){
this.currLocale=locale;
return true;
}
}
return false;
}
}//Ende: public class TestInputMethod implements InputMethod
//###################################################
---------- END SOURCE ----------