PopupMenuExample

import java.awt.*;

import java.awt.event.*;

 

public class PopupMenuExample implements ActionListener{

  Frame f;

  Button b;

  PopupMenu pm;

 

  public static void main(String args[]){

    PopupMenuExample pme=new PopupMenuExample();

    pme.init();

  }

 

  void init(){

    f=new Frame("PopupMenu Example");

    b=new Button("Press me");

    b.addActionListener(this);

    f.add(b,"Center");

 

    pm=new PopupMenu("Popup");

    pm.add(new MenuItem("New"));

    pm.add(new MenuItem("Load"));

    pm.add(new MenuItem("Sava"));

    pm.add(new MenuItem("Sava as..."));

    f.add(pm);

    f.setVisible(true);

  }

 

  public void actionPerformed(ActionEvent e){

    pm.show(b,10,10);

  }

}

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭