import javax.swing.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
class MyToolbox extends JFrame
{
JMenuBar menubar;
JMenu menu1,menu2;
JMenuItem item1,item2,item3;
MyToolbox(String s)
{
super(s);
setBounds(120,120,160,170);
setVisible(true);
menubar=new JMenuBar();
menu1=new JMenu("工具箱");
menu2=new JMenu("版本说明");
item1=new JMenuItem("计算器",new ImageIcon("jisuanqi.gif"));
item2=new JMenuItem("日历",new ImageIcon("rili.gif"));
item3=new JMenuItem("记事本",new ImageIcon("jishiben.gif"));
item1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J,InputEvent.CTRL_MASK));
item2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,InputEvent.CTRL_MASK));
item3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));
menu1.add(item1);
menu1.addSeparator();
menu1.add(item2);
menu1.addSeparator();
menu1.add(item3);
menubar.add(menu1);
menubar.add(menu2);
setJMenuBar(menubar);
validate();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}
public class TestMyToolbox
{
public static void main(String args[])
{
MyToolbox win=new MyToolbox("我的工具箱");
}
}