-
Bug
-
Resolution: Fixed
-
P5
-
1.1
-
None
-
1.1beta3
-
generic
-
windows_95
-
Not verified
Win95/NT and Solaris: Carriage Return (keyDown) have different values.
Workaround exists.
Source code example:
import java.awt.*;
import java.io.*;
public class Bug3
extends Frame
{
MenuBar testMenuBar;
Menu testMenu;
MenuItem exit;
public Bug3 (String Title)
{
super(Title);
setLayout (new BorderLayout());
testMenuBar = new MenuBar();
setMenuBar(testMenuBar);
testMenu = new Menu("TestMenu");
testMenuBar.add(testMenu);
exit = new MenuItem("Exit");
testMenu.add(exit);
}
// keyDown
public boolean keyDown(Event evt, int key)
{
//////////////////////////////////////////////////////////////////////
// bugNo 3 : carriage return gives key value \\r in NT/95 and \\n in UNIX
//////////////////////////////////////////////////////////////////////
if(key == '\t'){
System.out.println("Key down is \\t");
}
else if(key == '\r'){
System.out.println("Key down is \\r");
}
else if(key == '\n'){
System.out.println("Key down is \\n");
}
return false;
}
// handleEvent
public boolean handleEvent(Event event)
{
switch(event.id){
case Event.ACTION_EVENT:
if(event.target instanceof MenuItem){
if(event.target == exit){
System.exit(0);
}
}
break;
default:
break;
}
return super.handleEvent(event);
}
// main
public static void main(String args[])
{
Bug3 test = new Bug3("Bug3");
test.pack();
test.resize(400,200);
test.show();
}
}
Workaround exists.
Source code example:
import java.awt.*;
import java.io.*;
public class Bug3
extends Frame
{
MenuBar testMenuBar;
Menu testMenu;
MenuItem exit;
public Bug3 (String Title)
{
super(Title);
setLayout (new BorderLayout());
testMenuBar = new MenuBar();
setMenuBar(testMenuBar);
testMenu = new Menu("TestMenu");
testMenuBar.add(testMenu);
exit = new MenuItem("Exit");
testMenu.add(exit);
}
// keyDown
public boolean keyDown(Event evt, int key)
{
//////////////////////////////////////////////////////////////////////
// bugNo 3 : carriage return gives key value \\r in NT/95 and \\n in UNIX
//////////////////////////////////////////////////////////////////////
if(key == '\t'){
System.out.println("Key down is \\t");
}
else if(key == '\r'){
System.out.println("Key down is \\r");
}
else if(key == '\n'){
System.out.println("Key down is \\n");
}
return false;
}
// handleEvent
public boolean handleEvent(Event event)
{
switch(event.id){
case Event.ACTION_EVENT:
if(event.target instanceof MenuItem){
if(event.target == exit){
System.exit(0);
}
}
break;
default:
break;
}
return super.handleEvent(event);
}
// main
public static void main(String args[])
{
Bug3 test = new Bug3("Bug3");
test.pack();
test.resize(400,200);
test.show();
}
}