满意答案
leo.czy
2014.08.14
采纳率:42% 等级:8
已帮助:211人
可以啊 很简单的这是一个计算器的下拉菜单 代码public Computer() { this.setTitle("计算器"); this.setBounds(200,100,265,250); c = this.getContentPane(); menuBar = new JMenuBar(); this.setJMenuBar(menuBar); editMenu = new JMenu("编辑(E)"); viewMenu = new JMenu("查看(V)"); helpMenu = new JMenu("帮助(H)"); editMenu.setMnemonic('E'); viewMenu.setMnemonic('V'); helpMenu.setMnemonic('H'); copyMenuItem = new JMenuItem("复制"); copyMenuItem.setAccelerator(KeyStroke.getKeyStroke('C',Event.CTRL_MASK)); editMenu.add(copyMenuItem); pasteMenuItem = new JMenuItem("粘贴"); pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke('V',Event.CTRL_MASK)); editMenu.add(pasteMenuItem); standardMenuItem = new JRadioButtonMenuItem("标准型"); standardMenuItem.setAccelerator(KeyStroke.getKeyStroke('T',Event.CTRL_MASK)); viewMenu.add(standardMenuItem); ologyMenuItem = new JMenuItem("科学型"); ologyMenuItem.setAccelerator(KeyStroke.getKeyStroke('S',Event.CTRL_MASK)); viewMenu.add(ologyMenuItem); figMenuItem = new JMenuItem("数字分组"); figMenuItem.setAccelerator(KeyStroke.getKeyStroke('I',Event.CTRL_MASK)); viewMenu.add(figMenuItem); helpMotifMenuItem = new JMenuItem("帮助主题"); helpMotifMenuItem.setAccelerator(KeyStroke.getKeyStroke('H',Event.CTRL_MASK)); helpMenu.add(helpMotifMenuItem); aboutComputerMenuItem = new JMenuItem("关于计算器"); aboutComputerMenuItem.setAccelerator(KeyStroke.getKeyStroke('A',Event.CTRL_MASK)); helpMenu.add(aboutComputerMenuItem); menuBar.add(editMenu); menuBar.add(viewMenu); menuBar.add(helpMenu); this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //this.setResizable(false); this.setVisible(true); }自己看 看不懂再文我不知道你要做什么的
查看原帖>>
00分享举报