1
線程標題已經解釋了我的問題。這是一個已知的錯誤?我搜索了互聯網,但找不到解決方案。JMenuBar不顯示在Mac OS X Lion上,但在Win7上顯示
那麼,你可能知道該怎麼辦?
public static void main(String[] args) {
JFrame frame = new JFrame("Menu");
frame.setVisible(true);
frame.setSize(500,500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menubar = new JMenuBar();
frame.setJMenuBar(menubar);
JMenu file = new JMenu("File");
menubar.add(file);
JMenuItem exit = new JMenuItem("Exit");
file.add(exit);
JMenu help = new JMenu("Help");
menubar.add(help);
JMenuItem about = new JMenuItem("About");
help.add(about);
class exitAction implements ActionListener {
public void actionPerformed(ActionEvent e){
System.exit(0);
}
}
exit.addActionListener(new exitAction());
}
嘗試在添加完所有元素後設置菜單欄。 – 2012-02-23 17:27:47