learning java AWT widowEvent and MouseEvent
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener; public class WindowListenerTest { private Frame f = new Frame();
private TextArea ta = new TextArea(,);
private Button bt = new Button("bt");
public void init(){
f.addWindowListener(new MyListener());
bt.addMouseListener(new MyMouseListener());
f.add(bt,BorderLayout.NORTH);
f.add(ta);
f.pack();
f.setVisible(true);
}
class MyListener implements WindowListener{
public void windowOpened(WindowEvent e){
ta.append("window first be opened" + "\n");
} public void windowClosed(WindowEvent e){
ta.append("window closed " + "\n");
System.exit();
} public void windowClosing(WindowEvent e){
ta.append("window close by x" + "\n");
System.exit();
} public void windowIconified(WindowEvent e){
ta.append("window iconified be trigger" + "\n");
}
public void windowDeiconified(WindowEvent e){
ta.append("window deiconified be trigger" + "\n");
} public void windowActivated(WindowEvent e){
ta.append("window activated be trigger" + "\n");
} public void windowDeactivated(WindowEvent e){
ta.append("window deactivated be trigger" + "\n");
} }; class MyMouseListener implements MouseListener{
public void mouseEntered(MouseEvent event){
System.out.println("mouseEntered");
} public void mouseExited(MouseEvent event){
System.out.println("mouseExited");
}
public void mouseClicked(MouseEvent event){
System.out.println("mouseClicked");
}
public void mousePressed(MouseEvent event){
System.out.println("mousePressed");
}
public void mouseReleased(MouseEvent event){
System.out.println("mouseReleased");
} } public static void main(String[] args) {
new WindowListenerTest().init();
}
}
output:
learning java AWT widowEvent and MouseEvent的更多相关文章
- learning java AWT 手绘窗口
import java.awt.*;port java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import jav ...
- learning java AWT 右键菜单
import java.awt.*; import java.awt.event.*; public class SimpleMenu { private Frame f = new Frame(&q ...
- learning java AWT 剪贴板 传递文本
import javax.swing.*; import java.awt.*; import java.awt.datatransfer.Clipboard; import java.awt.dat ...
- learning java AWT 画图
import javax.swing.*; import java.awt.*; import java.util.Random; public class SimpleDraw { private ...
- learning java AWT MenuBar Menu MenuItem菜单
import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java ...
- learning java AWT EventQs
import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.Ac ...
- learning java AWT Dialog
import java.awt.*; public class DialogTest { Frame f = new Frame("test"); Dialog d1 = new ...
- learning java AWT 常见组件
import javax.swing.*; import java.awt.*; public class CommonComponent { Frame f = new Frame("te ...
- learning java AWT BoxLayout布局管理器
import javax.swing.*; import java.awt.*; public class BoxSpaceTest { private Frame f = new Frame(&qu ...
随机推荐
- Numpy学习笔记(上篇)
目录 Numpy学习笔记(上篇) 一.Jupyter Notebook的基本使用 二.Jpuyter Notebook的魔法命令 1.%run 2.%timeit & %%timeit 3.% ...
- Mybatis @One注解使用
@One注解:一对一关联查询
- AS3数字取整
AS3 数字取整方法int()去掉小数点trace(int(3.14)); //输出3trace(int(-3.14)); //输出-3Math.round()方法:Math.round()可以四舍五 ...
- 在 WPF 程序中应用 Windows 10 真?亚克力效果
原文:在 WPF 程序中应用 Windows 10 真?亚克力效果 从 Windows 10 (1803) 开始,Win32 应用也可以有 API 来实现原生的亚克力效果了.不过相比于 UWP 来说, ...
- 使用PrintDocument定制打印格式
虽然说使在IE上直接调用打印插件打印已经不常用,但是有时候还是会用到,这里就记录一下. 首先我们列出来我们的打印类 public class PrintService { //打印机名称 privat ...
- PDF时间戳 服务器
好用权威免费的PDF文件数字签名时间戳服务器URL http://tss.pki.gva.es:8318/tsa
- Objective-C和 C++ 混编的要点
Using C++ With Objective-C苹果的Objective-C编译器允许用户在同一个源文件里自由地混合使用C++和Objective-C,混编后的语言叫Objective-C++.有 ...
- element-ui DatePicker 日期格式处理
1.使用DatePicker 日期选择器得到的日期格式是这样的 解决方案,添加 value-format="yyyy-MM-dd" <el-date-picker type= ...
- 为新装的Centos 7X更换源,升级VIM失败,待解决
CentOS 7X使用阿里云CentOS的yum源 1.备份原有repo文件 #cd /etc/yum.repos.d #mv /etc/yum.repos.d/CentOS-Base.repo /e ...
- JavaScript箭头函数中的this详解
前言 箭头函数极大地简化了this的取值规则. 普通函数与箭头函数 普通函数指的是用function定义的函数: var hello = function () { console.log(" ...