Home > 类库下载 > java类库 > JAVA mouse event listening ACTIONLISTENER

JAVA mouse event listening ACTIONLISTENER

高洛峰
Release: 2016-10-13 09:55:34
Original
2169 people have browsed it

An action event occurs when the mouse is clicked and released;

Method summary:

actionPerformed(ActionEvent e)
Called when an operation occurs.

Column:

public class shijian extends Frame
{
  public static void main(String[] args)
  {
    Frame f = new Frame();
    f.setLayout(new FlowLayout(FlowLayout.LEFT,20,5));
    Button b1 = new Button("单机");
    Button b2 = new Button("双击");
    //Button b3 = new Button("a3");
    //创建监听器
    myactionlistener m = new myactionlistener();
    b1.addActionListener(m);//将m事件监听器注册个b1按钮
    f.add(b1);
    f.add(b2);
    //f.add(b3);
    f.pack();
    f.setVisible(true);
  }
}	
class myactionlistener implements ActionListener//实现一个监听器类
{
  @Override
  public void actionPerformed(ActionEvent e)
  {
  System.out.println("单机一");
  //System.exit(0); //用按钮关闭窗口
  }
}
Copy after login

JAVA mouse event listening ACTIONLISTENER

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template