谢谢!!!

解决方案 »

  1.   

    PopupMenu pop = new PopupMenu();
    Menu file = new Menu("file");
    MenuItem add = new MenuItem("add");
    MenuItem delete = new MenuItem("delete");

    pop.add(file);
    file.add(add);
    file.add(delete);一般都是这么用你再加个鼠标监听让它响应右键事件时show一下就OK啦
      

  2.   

    谢谢aaa2003gf() !!!还差一步:show(Component origin,  int x, int y)我作了一个按钮,想让他弹出菜单,结果
    Exception occurred during event dispatching:
    java.lang.NullPointerException: parent is nu
            at java/awt/PopupMenu.show
            at FTable.actionPerformed
            at java/awt/Button.processActionEven
            at java/awt/Button.processEvent
            at java/awt/Component.dispatchEventI
            at java/awt/Component.dispatchEvent
            at java/awt/EventDispatchThread.runAPI中说Shows the popup menu at the x, y position relative to an origin component. The origin component must be contained within the component hierarchy of the popup menu's parent. Both the origin and the parent must be showing on the screen for this method to be valid.我虽然看懂了,却不知错再哪,
      

  3.   

    //帮我看看错在哪import java.awt.*;
    import java.awt.event.*;class test2 extends Frame implements ActionListener  
     {Button b;
      public test2()
       {super("Welcome"); b=new Button("test"); 
        b.addActionListener(this); add(b,"Center"); pack();setVisible(true);
       }
      public void actionPerformed(ActionEvent e)
       {String s=e.getActionCommand();
        if(s.equals("test")) 
         {
          PopupMenu pop = new PopupMenu();
    Menu file = new Menu("file");
    MenuItem add = new MenuItem("add");
    MenuItem delete = new MenuItem("delete");

    pop.add(file);
    file.add(add);
    file.add(delete);
           pop.show(b,0,0);     }
       }
      public static void main(String args[])
       {test2 t=new test2();    }
     }
      

  4.   

    我知道了,要add(pop),已经可以正确运行谢谢!!!