-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.1.7
-
sparc
-
solaris_2.6
JDK 1.1.6 added input method support to support entry of multi-byte
characters on all AWT components which install a key listener.
The input method installs and deinstalls on the component in response
to focus events.
The bug is that the input method may not get de-installed from a component
when it loses focus, with the consequence that keyboard input is
misdirected and lost.
This bug appears on Solaris only, with JDK 1.1.6 and later which is
where the input method code was added.
I am not sure why it doesn't appear on NT, or JDK 1.2. It may be just
good fortune. I'll look into that later.
There is a scenario in which the focus out does not get delivered
to the component, meaning that the input method is still active even though
the component on which it is installed is no longer the active focus component.
This manifests itself in the application as non-entry of modified characters
when typing into the new text component with the input focus.
In the case which showed up this problem, a large and complex application
installed key listeners on all components, in part I believe so that it
could handle tab ordering and validation of all data entered.
One of these components was a button whose function was to bring
up a new Frame in which the user is to complete a task before returning
to the original frame. To prevent the user from manipulating the original
frame, whilst the 2nd frame was showing, it was disabled. So it acted like a
modal dialog.
Disabling the frame also disabled the button the user was pressing.
This translated (on Solaris) into a call to XtSetSensitive(false).
This prevents the underlying X libraries from delivering most events,
including focus events, on that Xt widget, up to the AWT Motif layer.
Thus the AWT never receives a focus out, and leaves the inout
method installed. So when new key events come in, the input method
code is called first from handleKeyEvent() in /src/solaris/sun/canvas.c
The test case below shows that modified (shifted keys, or when caps lock
is in effect) are passed through this route and not delivered to the
component with focus, but instead to the disabled button.
// EchoUpper.java
/* Bring up the app. Press caps lock, Type into the text field, note
* that alpha characters echo properly.
* Press the "Disable Me" button, try typing into the text field again.
* Note that characters no longer echo and that the event trace shows
* KEY_TYPED events being delivered to the button.
*/
import java.awt.*;
import java.awt.event.*;
public class EchoUpper extends Frame
implements KeyListener, ActionListener, FocusListener {
Button disable ;
public static void main(String args[]) {
new EchoUpper();
}
public EchoUpper() {
disable = new Button("Disable Me");
disable.addActionListener(this);
disable.addKeyListener(this);
disable.addFocusListener(this);
add("North", disable);
pack();
setVisible(true);
Frame frame2 = new Frame("Second Window");
TextField text = new TextField(20);
text.addActionListener(this);
text.addKeyListener(this);
text.addFocusListener(this);
frame2.add("Center", text);
frame2.pack();
frame2.setVisible(true);
frame2.setLocation(0,80);
}
public void actionPerformed(ActionEvent event) {
disable.setEnabled(false);
}
public void keyTyped(KeyEvent e) {
System.out.println("Key Typed: "+e);
}
public void keyPressed(KeyEvent e) {
System.out.println("Key Pressed: "+e);
}
public void keyReleased(KeyEvent e) {
System.out.println("Key Released: "+e);
}
public void focusGained(FocusEvent e) {
System.out.println("Focus Gained: "+e);
}
public void focusLost(FocusEvent e) {
System.out.println("Focus Lost: "+e);
}
}
characters on all AWT components which install a key listener.
The input method installs and deinstalls on the component in response
to focus events.
The bug is that the input method may not get de-installed from a component
when it loses focus, with the consequence that keyboard input is
misdirected and lost.
This bug appears on Solaris only, with JDK 1.1.6 and later which is
where the input method code was added.
I am not sure why it doesn't appear on NT, or JDK 1.2. It may be just
good fortune. I'll look into that later.
There is a scenario in which the focus out does not get delivered
to the component, meaning that the input method is still active even though
the component on which it is installed is no longer the active focus component.
This manifests itself in the application as non-entry of modified characters
when typing into the new text component with the input focus.
In the case which showed up this problem, a large and complex application
installed key listeners on all components, in part I believe so that it
could handle tab ordering and validation of all data entered.
One of these components was a button whose function was to bring
up a new Frame in which the user is to complete a task before returning
to the original frame. To prevent the user from manipulating the original
frame, whilst the 2nd frame was showing, it was disabled. So it acted like a
modal dialog.
Disabling the frame also disabled the button the user was pressing.
This translated (on Solaris) into a call to XtSetSensitive(false).
This prevents the underlying X libraries from delivering most events,
including focus events, on that Xt widget, up to the AWT Motif layer.
Thus the AWT never receives a focus out, and leaves the inout
method installed. So when new key events come in, the input method
code is called first from handleKeyEvent() in /src/solaris/sun/canvas.c
The test case below shows that modified (shifted keys, or when caps lock
is in effect) are passed through this route and not delivered to the
component with focus, but instead to the disabled button.
// EchoUpper.java
/* Bring up the app. Press caps lock, Type into the text field, note
* that alpha characters echo properly.
* Press the "Disable Me" button, try typing into the text field again.
* Note that characters no longer echo and that the event trace shows
* KEY_TYPED events being delivered to the button.
*/
import java.awt.*;
import java.awt.event.*;
public class EchoUpper extends Frame
implements KeyListener, ActionListener, FocusListener {
Button disable ;
public static void main(String args[]) {
new EchoUpper();
}
public EchoUpper() {
disable = new Button("Disable Me");
disable.addActionListener(this);
disable.addKeyListener(this);
disable.addFocusListener(this);
add("North", disable);
pack();
setVisible(true);
Frame frame2 = new Frame("Second Window");
TextField text = new TextField(20);
text.addActionListener(this);
text.addKeyListener(this);
text.addFocusListener(this);
frame2.add("Center", text);
frame2.pack();
frame2.setVisible(true);
frame2.setLocation(0,80);
}
public void actionPerformed(ActionEvent event) {
disable.setEnabled(false);
}
public void keyTyped(KeyEvent e) {
System.out.println("Key Typed: "+e);
}
public void keyPressed(KeyEvent e) {
System.out.println("Key Pressed: "+e);
}
public void keyReleased(KeyEvent e) {
System.out.println("Key Released: "+e);
}
public void focusGained(FocusEvent e) {
System.out.println("Focus Gained: "+e);
}
public void focusLost(FocusEvent e) {
System.out.println("Focus Lost: "+e);
}
}
- duplicates
-
JDK-4138877 JDK1.1.6: Solaris: Keyboard events are inproperly generated.
- Resolved