Name: dk106046 Date: 08/16/2004
OPERATING SYSTEM(S):
Linux (RH8.0, RHEL3/0, SLES8)
FULL JDK VERSION(S):
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
1. Build testcase: javac Test.java
import java.awt.*;
import java.awt.event.*;
public class Test extends Frame implements ActionListener{
Menu m, sm;
Label l1,l2;
Test(){
super("Test");
setLayout(new GridLayout(2,1));
m = new Menu("menu",true);
for(int i=0 ; i<3 ; i++){
MenuItem mi = new MenuItem("item "+i);
mi.addActionListener(this);
m.add(mi);
}
sm = new Menu("submenu");
for(int i=0 ; i<3 ; i++){
MenuItem mi = new MenuItem("sub item "+i);
mi.addActionListener(this);
sm.add(mi);
}
m.add(sm);
MenuBar mb = new MenuBar();
mb.add(m);
setMenuBar(mb);
Panel p = new Panel();
p.setLayout(new GridLayout(1,2));
l1 = new Label("Selected Menu Item:");
l2 = new Label("Nothing");
p.add(l1);
p.add(l2);
add(p);
Button Quit = new Button("Quit");
Quit.addActionListener(this);
add(Quit);
setSize(500, 300);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
String cmd = e.getActionCommand();
if(cmd == "Quit"){
System.exit(0);
}else{
l2.setText(cmd);
}
}
public static void main(String[] args){
Test t=new Test();
}
}
2. Run testcase: java Test
3. Click the menu to post its popup.
4. Click the "submenu" menu item so the sub menu is posted
5. Click the "submenu" menu item one more time so the submenu is hidden
6. After these operations,the Enter key or RightArrow key does not work for
the "submenu" menu item (ie, cannot post it's popup using the keyboard). <-------- PROBLEM!!
======================================================================