-
Bug
-
Resolution: Fixed
-
P4
-
1.1.6, 1.2.0
-
1.1.8
-
generic, sparc
-
generic, solaris_2.6
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2022877 | 1.2.2 | Robi Khan | P4 | Resolved | Fixed | 1.2.2 |
Name: mf23781 Date: 09/17/98
*Symptoms:
Upon testing the supplied code I found that the problem occurs on
Solaris with JDK1.1.6 and AIX JDK1.1.6 but works OK on WinNT with JDK 1.1.6
The keyEvent methods e.g. isAltDown, isControlDown, isShiftDown
do not work, except on Windows platforms.
Applet and html provided below, I've also created an Application version.
*Test case:
//------------------------------------------------------------------------------------------------------------------------------------
// html file keyTest.html follows:
//
<APPLET CODE=keyTest.class WIDTH=350 HEIGHT=350>
</APPLET>
//------------------------------------------------------------------------------------------------------------------------------------
// applet code keyTest.java follows:
//
import java.awt.*;
import java.applet.*;
import java.awt.event.ActionListener;
import java.awt.event.*;
public class keyTest extends Applet implements KeyListener{
TextArea ta;
TextField tf;
String theText;
public void init(){
setFont(new Font("Dialog",Font.PLAIN,12));
ta = new TextArea(8,30);
tf = new TextField(30);
tf.addKeyListener(this);
ta.addKeyListener(this);
// ta.setText("Hello");
// tf.setText("abcThere4567");
add(ta);
add(tf);
setBackground(Color.white);
}
public void keyTyped(KeyEvent e) { }
public void keyReleased(KeyEvent e) { }
public void keyPressed(KeyEvent evt)
{
char keyChar = evt.getKeyChar();
System.out.println("Key typed = " + keyChar);
if ( evt.isShiftDown() ) {
System.out.println("Modifier: Shift key is down");
}
if ( evt.isControlDown()) {
System.out.println("Modifier: Control key is down");
}
if ( evt.isAltDown() ) {
System.out.println("Modifier: Alt key is down");
}
if ( evt.isMetaDown() ) {
System.out.println("Modifier: Meta key is down");
}
}
private void handleEnter()
{
System.out.println("Enter key pressed!!");
}
public void paint(Graphics g) {
g.drawString("Use the alt or shift or ctrl modifier key when typing.",10,200);
g.drawString("Modifier only works with some keys (backspace is one)", 10,220);
}
public void start() {
}
}
//------------------------------------------------------------------------------------------------------------------------------------
// Application version keyTest2.java follows:
//
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.*;
public class keyTest2 extends Frame implements KeyListener{
TextArea ta;
TextField tf;
String theText;
public void init(){
setLayout(new GridLayout(0,1));
setFont(new Font("Dialog",Font.PLAIN,12));
ta = new TextArea(8,30);
tf = new TextField(30);
tf.addKeyListener(this);
ta.addKeyListener(this);
// ta.setText("Hello");
// tf.setText("abcThere4567");
add(ta);
add(tf);
setBackground(Color.white);
setSize(400,200);
}
public static void main(String[] args)
{
keyTest2 kt2 = new keyTest2();
kt2.init();
kt2.show();
}
public void keyTyped(KeyEvent e) { }
public void keyReleased(KeyEvent e) { }
public void keyPressed(KeyEvent evt)
{
char keyChar = evt.getKeyChar();
System.out.println("Key typed = " + keyChar);
if ( evt.isShiftDown() ) {
System.out.println("Modifier: Shift key is down");
}
if ( evt.isControlDown()) {
System.out.println("Modifier: Control key is down");
}
if ( evt.isAltDown() ) {
System.out.println("Modifier: Alt key is down");
}
if ( evt.isMetaDown() ) {
System.out.println("Modifier: Meta key is down");
}
if ( (keyChar == 'X') || (keyChar == 'x')) {
System.exit(0);
}
}
}
======================================================================
- backported by
-
JDK-2022877 KeyEvent modifiers not working on unix platforms
- Resolved
- relates to
-
JDK-4218580 KeyEvent modifiers not sent for KEY_TYPED events on Solaris
- Closed
-
JDK-4182178 "isControlDown" doesn't work.
- Closed
-
JDK-4220772 Key modifiers not passed for KEY_TYPED events on Solaris
- Closed
-
JDK-4193779 Modifiers not delivered with KEY_TYPED events on Solaris.
- Resolved
-
JDK-4209844 Modifiers not set for KEY_TYPED events on win32
- Closed
(1 relates to)