-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.2.0
-
sparc
-
solaris_2.6
Name: tb29552 Date: 09/30/98
The following code HALF works in 1.1.6: It prints out
Typed events, but not Pressed events.
With 1.1.7, however, NO key events seem to come
through.
Interestingly, if you comment out the block in
the constructor that adds the Canvas widget, it
works fine.
import java.awt.*;
import java.awt.event.*;
class jtest extends Frame implements KeyListener, MouseListener {
Canvas dummy;
static void print(String msg){ System.out.println(msg);}
public void mouseEntered(MouseEvent evt) {
print("asking for focus");
requestFocus();
}
public void mouseExited(MouseEvent evt) {}
public void mouseClicked(MouseEvent evt) {}
public void mousePressed(MouseEvent evt) {}
public void mouseReleased(MouseEvent evt) {}
public void keyPressed(KeyEvent evt) {
print("Pressed: "+evt.getKeyChar());
}
public void keyTyped(KeyEvent evt) {
print("Typed: "+evt.getKeyChar());
}
public void keyReleased(KeyEvent evt) {}
public jtest(){
setTitle("test frame");
dummy=new Canvas();
add(new Canvas());
dummy.setSize(300,300);
dummy.addKeyListener(this);
dummy.addMouseListener(this);
setSize(300,300);
addKeyListener(this);
addMouseListener(this);
}
public static void main(String args[]){
jtest top = new jtest();
top.setVisible(true);
print("Press a key in the window");
}
}
(Review ID: 39628)
======================================================================
- relates to
-
JDK-4066152 4032657 - Canvas Doesn't receive Key Events (1.1.x only)
-
- Closed
-