오버라이딩된부분만 보면됌
import java.awt.SystemColor;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class WindowEventTest extends JFrame implements WindowListener{
JLabel lbl = new JLabel("계산기");
Calculator cal = new Calculator();
public WindowEventTest() {
add("North",lbl);
add(cal);
setSize(500,300);
setVisible(true);
//프로그램 종료시 자원해제
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
//창닫기 금지
//setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(this);
}
public static void main(String[] args) {
new WindowEventTest();
}
@Override
public void windowOpened(WindowEvent e) {
System.out.println("Opened()");
}
@Override
public void windowClosing(WindowEvent e) {
int state = JOptionPane.showConfirmDialog(this, "종료하시겠습니까?","종료확인",JOptionPane.YES_NO_OPTION);
if(state == JOptionPane.YES_NO_OPTION) {
System.exit(0);
}
}
@Override
public void windowClosed(WindowEvent e) {
System.out.println("Closed()");
}
@Override
public void windowIconified(WindowEvent e) {
System.out.println("Iconfied()");
}
@Override
public void windowDeiconified(WindowEvent e) {
System.out.println("Deiconified()");
}
@Override
public void windowActivated(WindowEvent e) {
System.out.println("Activated()");
}
@Override
public void windowDeactivated(WindowEvent e) {
System.out.println("Deactuvated()");
}
}
'language > java실습' 카테고리의 다른 글
[JFrame,java,자바,GUI] 달력만들기 (2) | 2021.01.19 |
---|---|
[java,자바] JFrame Window메소드 알아보기 (0) | 2021.01.14 |
[java,자바] JFrame 이용하여 계산기 (0) | 2021.01.14 |
[java,자바] GUI 스윙기초 이용 및 실습 (0) | 2021.01.12 |
[java,자바] 이클립스 자바 API 도움말 한글로나오게 설정하기 (0) | 2021.01.12 |
최근댓글