learning java AWT EventQs
2024-08-26 11:13:25
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; public class EventQs {
private Frame f = new Frame("event test");
private Button ok = new Button("confired");
private TextField tf = new TextField();
public void init(){
ok.addActionListener(new OkListener());
f.add(tf);
f.add(ok, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
} class OkListener implements ActionListener{
public void actionPerformed(ActionEvent e){
System.out.println("button be pressed");
tf.setText("hello panzidong"); }
}
public static void main(String[] args) {
new EventQs().init();
}
}
output:
最新文章
- Kotlin开发语言文档(官方文档)-- 目录
- 《learning hard C#学习笔记》读书笔记(19)多线程
- Mac Mail PGP Setup 如何在苹果电脑上设置安全邮件 良好隐私密码法(英语:Pretty Good Privacy,缩写为PGP)
- VC++ 判断文件或文件夹是否存在的快捷方法 _access
- Java Web整合开发实战:基于Struts 2+Hibernate+Spring 目录
- eclipse报jvm terminated.exitcode=2异常解决办法
- Warning: Name is nonexistent or not a directory
- SATA1.0,2.0,3.0区别
- Main方法中传入参数
- JVM调优总结(七)-典型配置举例1
- Counting Stars
- VS编辑器主题变换插件-EasyVS
- [Swift]LeetCode290. 单词模式 | Word Pattern
- SQL Server Management Studio 执行超大脚本文件
- JavaScript 笔记(一)
- reactNative 基础
- k8s部署prometheus
- go struct结构体
- Centos7部署kubernetes-ETCD集群(三)
- MVC、MVP和MVVM的异同