JAVA mouse event listening ACTIONLISTENER
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
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
What's New in Windows 11 KB5054979 & How to Fix Update Issues
4 weeks ago
By DDD
How to fix KB5055523 fails to install in Windows 11?
3 weeks ago
By DDD
InZoi: How To Apply To School And University
1 months ago
By DDD
How to fix KB5055518 fails to install in Windows 10?
3 weeks ago
By DDD
Where to find the Site Office Key in Atomfall
1 months ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
