selflistener.java

来自「东软JAVA内部资料」· Java 代码 · 共 76 行

JAVA
76
字号
package org.course.gui;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class SelfListener extends Frame implements WindowListener{
	Button bClose;
	public SelfListener() {
		super("Listener is itself");
		bClose = new Button("close");
		this.add(bClose, BorderLayout.SOUTH);
		
		this.addWindowListener(this);
		bClose.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				close();
				
			}
			
		});
		
		this.setSize(400, 300);
		this.setVisible(true);	
		
	}
	
	void close() {
		this.dispose();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new SelfListener();
	}

	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowClosing(WindowEvent e) {
		// TODO Auto-generated method stub
		this.dispose();
	}

	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?