你是用的下面的方法吗?
jFrame.setJMenuBar(jMenubar);

解决方案 »

  1.   

    估计是你把菜单什么的加到JPanel上去了,而不是Jframe上。
      

  2.   

    是啊,jFrame.setJMenuBar(jMenubar);方法不错.
      

  3.   

    代码是这样的:
    public class Lab extends JApplet 
    {
     public void init() {
     setJMenuBar(mb);
     JToolBar toolBar1 = new JToolBar();
      JToolBar toolBar2=new JToolBar();
    Panel tbPanel=new Panel();
        tbPanel.setLayout(new GridLayout(2,1));
        tbPanel.add(toolBar1);
        tbPanel.add(toolBar2);
        getContentPane().add(tbPanel,BorderLayout.NORTH );}}
      

  4.   

    你的菜单应该加到rootPane,工具条应该加到别的面板上去。
    gRootPane.setMenuBar(mb);
      

  5.   

    抱歉,说的有点不对,下面的代码我试过没问题,如果有问题的话可能就是你的JApplet的paint方法被重写了。
    this.getContentPane().setLayout(new BorderLayout());
        jMenu2.setText("gfhf");
        jMenuItem1.setText("sh");
        jMenu3.setText("fghh");
        jCheckBox1.setText("jCheckBox1");
        jPasswordField1.setText("jPasswordField1");
        this.setJMenuBar(jMenuBar1);
        jCheckBox2.setText("jCheckBox2");
        jPasswordField2.setText("jPasswordField2");
        jMenuBar1.add(jMenu2);
        jMenuBar1.add(jMenu3);
        jMenu2.add(jMenuItem1);
        JPanel tbPanel=new JPanel();
        tbPanel.setLayout(new GridLayout(2,1));
        tbPanel.add(jToolBar1);
        tbPanel.add(jToolBar2);
        jToolBar2.add(jCheckBox2, null);
        jToolBar2.add(jPasswordField2, null);
        this.getContentPane().add(tbPanel, BorderLayout.NORTH);
        jToolBar1.add(jPasswordField1, null);
        jToolBar1.add(jCheckBox1, null);
      

  6.   

    thank you very much!
    我是先把程序实现了,然后又把界面作了,单独运行都没问题,合一块就出上面的问题
    我确实重写了paint()方法,如下:
    public class aa {
    Image image;
     void DrawImage(JApplet app,Graphics g)
        {
      image=app.getImage(app.getCodeBase(),"res/aa.jpg");
      g.drawImage(image,m_pos.x,m_pos.y,app); } //m_pos是image的当前位置}
    aa pCom;
    public void paint(Graphics g)
    {
    paintComponents(g);
    pCom.DrawImage(this,g);
    }
    如果不写paintComponents(g);菜单显示不出来
    如果不重写paint(),我定义的类就没法画图.
      

  7.   

    其实你可以在一个JPanel上绘图,然后把它加到JApplet上就没有问题了。
    public class BackMapPanel extends JPanel {
      Image image = null;
      BorderLayout borderLayout1 = new BorderLayout();  public BackMapPanel(Image image) {
        super();
        this.image = image;
        try {
          jbInit();
        }
        catch(Exception ex) {
          ex.printStackTrace();
        }
      }
      void jbInit() throws Exception {
        //SwingUtilities.updateComponentTreeUI(this);
        this.setLayout(borderLayout1);
      }  public void paintComponent(Graphics g)
      {
        //System.out.println(image.toString());
        if(this.image!=null)
          g.drawImage(image,0,0,image.getWidth(this),image.getHeight(this),null,this);
        else
          g.drawString("找不到图片",50,50);
       // this.updateUI();
       g.dispose();
      }
    }