转自:http://bbs.chinaunix.net/forum/26/20030827/148099.html首先在Applet的init() 方法中建立Frame instance, 然后将Menus, Menubar都加上去即可。 (setMenuBar() 是 Frame下的方法)或者,找到Applet上层的Frame后依法炮制。 Container parent = getParent(); while (! (parent instanceof Frame) ) parent = parent.getParent(); Frame theFrame = (Frame) parent; 注意:第二个方法在Mac或某些browsers上并不可行。 如果您使用的是JDK 1.1,也可以考虑使用popup menu,这样就不必理会Frame的问题了。

解决方案 »

  1.   

    刚才是转贴,说得不清楚。
    其实是由于菜单不是从Component类派生出来的,不能用add方法在容器中添加菜单组件,而Menu、MenuBar和Frame都实现了setMenuBar方法,用它可以添加菜单条。
    方法:
    在init()中添加:
            Frame myFrame = new Frame("myFrame Sample");//声明一个框架来包含菜单
            myFrame.setSize(250,250);//设置Frame大小
            myFrame.setMenuBar(menuBar1);//添加
            myFrame.show();//显示
      

  2.   

    你可以换成javax.swing包试一下
      

  3.   

    请问楼上的老兄:Applet中可以用swing组件??^_^ 你做过?给你的源码看看如何???
      

  4.   

    It's important to remember when designing applets that browser support for Java can be limited (depending on the browser you use). If you design your applet using Java AWT components, which are generally supported by most browsers, such as Netscape Navigator and Microsoft Internet Explorer. However, if you want to design an applet using Swing components, you need to determine what Java capabilities your browser supports. Generally, you can find browser support information for Java applets by looking in the Tools, Preferences, or Help menu contents of Netscape or Internet Explorer. The safest way to design your applet is by using AWT components and the JDK that the browser supports.
    If you create your applet using javax.swing.JApplet, your applet won't run in most web browsers. At the time of this writing, Swing is not yet supported by the web browsers.
      

  5.   

    是呀,还没有浏览器支持swing组件的.