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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
2 weeks ago
By DDD
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

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)

Hot Topics
CakePHP Tutorial
1378
52

