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:

最新文章

  1. Kotlin开发语言文档(官方文档)-- 目录
  2. 《learning hard C#学习笔记》读书笔记(19)多线程
  3. Mac Mail PGP Setup 如何在苹果电脑上设置安全邮件 良好隐私密码法(英语:Pretty Good Privacy,缩写为PGP)
  4. VC++ 判断文件或文件夹是否存在的快捷方法 _access
  5. Java Web整合开发实战:基于Struts 2+Hibernate+Spring 目录
  6. eclipse报jvm terminated.exitcode=2异常解决办法
  7. Warning: Name is nonexistent or not a directory
  8. SATA1.0,2.0,3.0区别
  9. Main方法中传入参数
  10. JVM调优总结(七)-典型配置举例1
  11. Counting Stars
  12. VS编辑器主题变换插件-EasyVS
  13. [Swift]LeetCode290. 单词模式 | Word Pattern
  14. SQL Server Management Studio 执行超大脚本文件
  15. JavaScript 笔记(一)
  16. reactNative 基础
  17. k8s部署prometheus
  18. go struct结构体
  19. Centos7部署kubernetes-ETCD集群(三)
  20. MVC、MVP和MVVM的异同

热门文章

  1. WITH AS学习
  2. Spring MVC前端控制器不拦截静态资源配置
  3. Node模块化
  4. 记录用到的mssql的几个方法
  5. java 单链表反转
  6. 关闭 OSX 10.11 SIP (System Integrity Protection) 功能
  7. MySQL Replication--修复从库上单个数据库的数据
  8. Android笔记(五十) Android中的JSON数据
  9. c# Queue 类
  10. wget下载出现错误 403:Forbidden