我要用JMenu添加子项该怎么做???JMenuBar与JMenuItem怎么做???

解决方案 »

  1.   

    An implementation of a menu -- a popup window containing JMenuItems that is displayed when the user selects an item on the JMenuBar. In addition to JMenuItems, a JMenu can also contain JSeparators. 
    搞清三者关系就知道谁add谁了
    JMenu是选择了JMenuBar上一个选项之后弹出的一个包含JMenuItems的popup window
      

  2.   

    给你个例子: JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar); JMenu menu1 = new JMenu("File");
    menuBar.add(menu1); JMenuItem exitItem = new JMenuItem("Exit");
      

  3.   

    http://topic.csdn.net/u/20080311/19/ebc8809b-6ec8-483e-9d29-3d7d9182d487.html
    9楼   有代码,可运行 
      

  4.   

    JMenuBar包含JMenu,JMenu中有多个JMenuItem,
    在一般的窗口中,文件,编辑,工具,帮助等都应该叫做菜单(JMenu),然后文件下面的“打开”,“新建”,“退出”等叫做菜单项(JMenuItem),然后那些菜单都放在一个叫做菜单栏中(JMenuBar)。用过Firefox就知道,有一个选项是移除菜单栏,而不是移除菜单。移除一个组件,他的子组件也会一起移除的,所以一移除掉菜单栏,菜单,菜单项等都被一起移除掉了。