GUI(JMenuBar+JMenu+JMenuItem)

public class WindowMenu extends JFrame {
JMenuBar menubar;
JMenu menu,subMenu;
JMenuItem item1,item2; public WindowMenu(){}
public WindowMenu(String s ,int x,int y,int w,int h){
init(s);
setLocation(x, y);
setSize(w, h);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
} private void init(String s) {
setTitle(s);
menubar = new JMenuBar();
menu = new JMenu("菜单");
subMenu = new JMenu("软件项目");
item1 = new JMenuItem();
item1 = new JMenuItem("动画话题",new ImageIcon("src/picture/dm.png"));
item2 = new JMenuItem("java话题",new ImageIcon("src/picture/java.png"));
item1.setAccelerator(KeyStroke.getKeyStroke("A"));
item2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));
menu.add(item1);
menu.addSeparator();
menu.add(item2);
menubar.add(menu);
menu.add(subMenu);
subMenu.add(new JMenuItem("汽车销售系统",new ImageIcon("src/picture/dm.png")));
subMenu.add(new JMenuItem("农场信息系统",new ImageIcon("src/picture/java.png")));
setJMenuBar(menubar); }
}
上一篇:$("#id").val()取值textarea是""


下一篇:11月20日云栖日报:波士顿的动力机器狗在2020年中客户使用量或达1000台;8元买3万张人脸照片,谁在买卖你的“脸”?