4
這是我到目前爲止的代碼:如何從菜單欄打開新窗口?
public static void main(String[] args){
JFrame frame = new JFrame("Breakout!");
frame.setLocation(300, 300);
//Making the menubar
JMenuBar mb = new JMenuBar();
frame.setJMenuBar(mb);
JMenu fileMenu = new JMenu("File");
mb.add(fileMenu);
JMenuItem newAction = new JMenuItem("About");
fileMenu.add(newAction);
newAction.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.out.println("open new window here");
}
});
BreakoutCourt c = new BreakoutCourt();
frame.add(c);
frame.pack();
frame.setResizable(false);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
我想提出一個突圍賽。我想創建一個顯示關於遊戲信息的關於窗口(如,如何播放等)。我會怎麼做呢?感謝您的幫助!我對Java Swing很陌生,所以是的。
非常有幫助!非常感謝!! – flymonkey 2012-04-25 01:14:11
+1另請參閱[使用多個JFrames,好/壞實踐?](http://stackoverflow.com/a/9554657/418556) – 2012-04-25 08:12:01