-
Bug
-
Resolution: Fixed
-
P1
-
1.1
-
1.1.1
-
generic
-
generic
-
Not verified
On both Win32 and Solaris MenuShortcut doesn't work at all.
import java.awt.* ;
import java.awt.event.* ;
public class MenuShortcutTest extends java.applet.Applet {
Frame window ;
public void init() {
window = new MyFrame("test case of java.awt.MenuItem") ;
window.resize(300,150) ;
window.show() ;
}
}
class MyFrame extends Frame {
Label l ;
MenuShortcut f1 = new MenuShortcut(KeyEvent.VK_1,false) ;
// MenuShortcut f2 = new MenuShortcut(KeyEvent.VK_2,false) ;
// MenuShortcut f3 = new MenuShortcut(KeyEvent.VK_3,false) ;
MenuShortcut f2 = new MenuShortcut(KeyEvent.VK_G,false) ;
MenuShortcut f3 = new MenuShortcut(KeyEvent.VK_B,false) ;
MenuItem rmi = new MenuItem("Red",f1) ;
MenuItem bmi = new MenuItem("Blue",f2) ;
MenuItem gmi = new MenuItem("Green",f3) ;
menuItemActionListener mial = new menuItemActionListener() ;
MyFrame(String title) {
super(title) ;
MenuBar mb = new MenuBar() ;
Menu m = new Menu("Colors") ;
rmi.setActionCommand("RED") ;
bmi.setActionCommand("BLUE") ;
gmi.setActionCommand("GREEN") ;
rmi.addActionListener(mial) ;
bmi.addActionListener(mial) ;
gmi.addActionListener(mial) ;
m.add(rmi) ;
m.add(bmi) ;
m.add(gmi) ;
mb.add(m) ;
setMenuBar(mb) ;
setLayout(new FlowLayout(FlowLayout.CENTER)) ;
l = new Label("Please select menuitem by shortcut-key", Label.CENTER) ;
add (l) ;
}
class menuItemActionListener implements ActionListener {
public void actionPerformed(ActionEvent evnt) {
String label = evnt.getActionCommand() ;
if (label.equals("RED")) {
setBackground(Color.red) ;
setForeground(Color.yellow) ;
repaint() ;
}
else if (label.equals("BLUE")) {
setBackground(Color.blue) ;
setForeground(Color.magenta) ;
repaint() ;
}
else if (label.equals("GREEN")) {
setBackground(Color.green) ;
setForeground(Color.orange) ;
repaint() ;
}
}
}
}
import java.awt.* ;
import java.awt.event.* ;
public class MenuShortcutTest extends java.applet.Applet {
Frame window ;
public void init() {
window = new MyFrame("test case of java.awt.MenuItem") ;
window.resize(300,150) ;
window.show() ;
}
}
class MyFrame extends Frame {
Label l ;
MenuShortcut f1 = new MenuShortcut(KeyEvent.VK_1,false) ;
// MenuShortcut f2 = new MenuShortcut(KeyEvent.VK_2,false) ;
// MenuShortcut f3 = new MenuShortcut(KeyEvent.VK_3,false) ;
MenuShortcut f2 = new MenuShortcut(KeyEvent.VK_G,false) ;
MenuShortcut f3 = new MenuShortcut(KeyEvent.VK_B,false) ;
MenuItem rmi = new MenuItem("Red",f1) ;
MenuItem bmi = new MenuItem("Blue",f2) ;
MenuItem gmi = new MenuItem("Green",f3) ;
menuItemActionListener mial = new menuItemActionListener() ;
MyFrame(String title) {
super(title) ;
MenuBar mb = new MenuBar() ;
Menu m = new Menu("Colors") ;
rmi.setActionCommand("RED") ;
bmi.setActionCommand("BLUE") ;
gmi.setActionCommand("GREEN") ;
rmi.addActionListener(mial) ;
bmi.addActionListener(mial) ;
gmi.addActionListener(mial) ;
m.add(rmi) ;
m.add(bmi) ;
m.add(gmi) ;
mb.add(m) ;
setMenuBar(mb) ;
setLayout(new FlowLayout(FlowLayout.CENTER)) ;
l = new Label("Please select menuitem by shortcut-key", Label.CENTER) ;
add (l) ;
}
class menuItemActionListener implements ActionListener {
public void actionPerformed(ActionEvent evnt) {
String label = evnt.getActionCommand() ;
if (label.equals("RED")) {
setBackground(Color.red) ;
setForeground(Color.yellow) ;
repaint() ;
}
else if (label.equals("BLUE")) {
setBackground(Color.blue) ;
setForeground(Color.magenta) ;
repaint() ;
}
else if (label.equals("GREEN")) {
setBackground(Color.green) ;
setForeground(Color.orange) ;
repaint() ;
}
}
}
}