java窗口,菜单栏出不来,求大侠帮助!!
/** 做一个窗口 里面有文件选项,文件里有子菜单,可以打开,保存等import javax.swing.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
public class Example10_2{
public static void main(String agrs[]){
FirstWindow win=new FirstWindow("first 窗口");
}
}
class FirstWindow extends JFrame{
JMenuBar menubar;
JMenu menu;
JMenuItem item1,item2;
FirstWindow (String s){
setTitle("一个窗口");
setSize(500,500);
setLocation(120,120);
setVisible(true);
menubar=new JMenuBar();
menu=new JMenu("文件");
item1=new JMenuItem("打开",new ImageIcon("open.gif"));
item2=new JMenuItem("保存",new ImageIcon("save.gif"));
item1.setAccelerator(KeyStroke.getKeyStroke('o'));
item2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));
menu.add(item1);
menu.addSeparator();
menu.add(item2);
menu.add(menu);
setJMenuBar(menubar);
validate();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
}