오버라이딩 (Overriding)

Similar documents
<4D F736F F F696E74202D20C1A63138C0E520C0CCBAA5C6AE20C3B3B8AE28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint - 06-Chapter09-Event.ppt

Cluster management software

10장.key

슬라이드 1

(Microsoft PowerPoint - LZVNQBAJWGTC.ppt [\310\243\310\257 \270\360\265\345])

JAVA PROGRAMMING 실습 08.다형성

자바로

gnu-lee-oop-kor-lec10-1-chap10

Microsoft PowerPoint - EEL2 Lecture10 -Swing and Event Handling.pptx

PowerPoint Presentation

public class FlowLayoutPractice extends JFrame { public FlowLayoutPractice() { super("flowlayout Practice"); this. Container contentpane = getcontentp

Microsoft PowerPoint - ÀÚ¹Ù08Àå-1.ppt

Microsoft PowerPoint - 10장

<4D F736F F F696E74202D20C1A63236C0E520BED6C7C3B8B428B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint - lec09_12.ppt [호환 모드]

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

PowerPoint Presentation

PowerPoint 프레젠테이션

제11장 프로세스와 쓰레드

PowerPoint Presentation

PowerPoint 프레젠테이션

(Microsoft PowerPoint - java1-lecture7.ppt [\310\243\310\257 \270\360\265\345])

Design Issues

운동시뮬레이션 강의 소개

PowerPoint 프레젠테이션

<4D F736F F F696E74202D205B4A415641C7C1B7CEB1D7B7A1B9D65D3130C0E5C0CCBAA5C6AEC3B3B8AE>

歯NetworkKawuiBawuiBo.PDF

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

9장.key

PowerPoint Presentation

Microsoft PowerPoint - java1-lecture10.ppt [호환 모드]

Microsoft PowerPoint - 14주차 강의자료

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1"); void method() 2"); void method1() public class Test 3"); args) A

PowerPoint Presentation

제8장 자바 GUI 프로그래밍 II

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

쉽게 풀어쓴 C 프로그래밍

Microsoft PowerPoint - 04-UDP Programming.ppt

[ 그림 8-1] XML 을이용한옵션메뉴설정방법 <menu> <item 항목ID" android:title=" 항목제목 "/> </menu> public boolean oncreateoptionsmenu(menu menu) { getme

2 단계 : 추상화 class 오리 { class 청둥오리 extends 오리 { class 물오리 extends 오리 { 청둥오리 mallardduck = new 청둥오리 (); 물오리 redheadduck = new 물오리 (); mallardduck.swim();

rmi_박준용_final.PDF

ch09

System Patterns - Session

PowerPoint Template

Microsoft PowerPoint - CSharp-10-예외처리

자바GUI실전프로그래밍2_장대원.PDF

Network Programming

10 이벤트 처리와 그래픽 프로그래밍.key

Microsoft PowerPoint - 2강

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

PowerPoint Presentation

PowerPoint Presentation

05-class.key

제목

중간고사

A Tour of Java V

강의자료

No Slide Title

어댑터뷰

JAVA PROGRAMMING 실습 02. 표준 입출력

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

JMF1_심빈구.PDF

Cluster management software

Chap12

gnu-lee-oop-kor-lec06-3-chap7

PowerPoint 프레젠테이션

Microsoft Word - ntasFrameBuilderInstallGuide2.5.doc

09-interface.key

PowerPoint Presentation

. 스레드 (Thread) 란? 스레드를설명하기전에이글에서언급되는용어들에대하여알아보도록하겠습니다. - 응용프로그램 ( Application ) 사용자에게특정서비스를제공할목적으로구현된응용프로그램을말합니다. - 컴포넌트 ( component ) 어플리케이션을구성하는기능별요

Microsoft PowerPoint - RMI.ppt

5장.key

Spring Data JPA Many To Many 양방향 관계 예제

No Slide Title

01-OOPConcepts(2).PDF

Spring Boot

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint - Java-03.pptx

13ÀåÃß°¡ºÐ

쉽게 풀어쓴 C 프로그래밍

JAVA PROGRAMMING 실습 09. 예외처리

menu_10p_all_161020_cs6

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

PowerPoint 프레젠테이션

PowerPoint Presentation

9 차시고급위젯다루기 1 학습목표 날짜 / 시간과관련된위젯을배운다. 웹뷰를사용하여간단한웹브라우저기능을구현한다. 매니패스트파일의설정법을배운다. 2 확인해볼까? 3 날짜 / 시간위젯 1) 활동하기 활동개요

API - Notification 메크로를통하여어느특정상황이되었을때 SolidWorks 및보낸경로를통하여알림메시지를보낼수있습니다. 이번기술자료에서는메크로에서이벤트처리기를통하여진행할예정이며, 메크로에서작업을수행하는데유용할것입니다. 알림이벤트핸들러는응용프로그램구현하는데있어

제13강. 스윙(Swing)

JUNIT 실습및발표

ThisJava ..

PowerPoint Presentation

DB 에데이터저장을위한입력창설계 - JLabel, JTextField, JButton 을이용한입력창설계 - 2 -

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Microsoft Word - java19-1-midterm-answer.doc

<4D F736F F F696E74202D20C1A63034B0AD202D20C7C1B7B9C0D3B8AEBDBAB3CABFCD20B9ABB9F6C6DBC0D4B7C2>

Java Programing Environment

슬라이드 1

게임 기획서 표준양식 연구보고서

Transcription:

WindowEvent WindowEvent 윈도우가열리거나 (opened) 닫힐때 (closed) 활성화되거나 (activated) 비활성화될때 (deactivated) 최소화되거나 (iconified) 복귀될때 (deiconified) 윈도우닫힘버튼을누를때 (closing)

WindowEvent 수신자 abstract class WindowListener { abstract void windowactivated(windowevent e); abstract void windowdeactivated(windowevent e); abstract void windowiconified(windowevent e); abstract void windowdeiconified(windowevent e); abstract void windowopened(windowevent e); abstract void windowclosed(windowevent e); abstract void windowclosing(windowevent e);

WindowEvent 수신자코드구현 Class MyListener implements WindowListener { public void windowactivated(windowevent e) { public void windowdeactivated(windowevent e) { public void windowiconified(windowevent e) { public void windowdeiconified(windowevent e) { public void windowopened(windowevent e) { public void windowclosed(windowevent e) { public void windowclosing(windowevent e) {

WindowEvent 수신자등록하기 void addwindowlistener(windowlistener listener) class MyFrame extends JFrame { MyFrame() { addwindowlistener(new MyListener()); class MyListener implements WindowListener {

WindowEvent 예제 : 윈도우닫힘버튼의처리 windowclosing() 메소드에서 System.exit() 사용 JFrame.setDefaultCloseOperation() 메소드사용 (JDK 1.4 이후 ) EXIT_ON_CLOSE DO_NOTHING_ON_CLOSE HIDE_ON_CLOSE (default) DISPOSE_ON_CLOSE 종료전재확인하는방법

WindowListener vs. WindowAdapter WindowListener 인터페이스문제점 7가지의메소드를모두구현해야 windowclosing() 을제외한 6가지는사실상거의사용되지않는다. 사용하지않아도빈코드로구현은해야 불편! 어댑터클래스 인터페이스의모든메소드를빈코드로구현 실제로사용되는메소드는치환 (overriding) 으로코드변경

WindowListener vs. WindowAdapter WindowAdapter 클래스 : 빈코드로메소드구현! class WindowAdapter implements WindowListener { public void windowactivated(windowevent e) { public void windowdeactivated(windowevent e) { public void windowiconified(windowevent e) { public void windowdeiconified(windowevent e) { public void windowopened(windowevent e) { public void windowclosed(windowevent e) { public void windowclosing(windowevent e) {

WindowListener vs. WindowAdapter MyListener WindowListener 를 implement 하든지, (7 개의메소드모두 ) WindowAdapter 를상속받든지 ( 필요한메소드만치환 ) class MyListener implements WindowListener { 7 가지메소드모두코드구현 또는, class MyListener extends WindowAdapter { 필요한메소드만치환

WindowAdapter 사용시자기수신자로만들기어려움 class MyFrame extends JFrame { MyFrame() { add(new MyListener()); class MyListener extends WindowAdapter { WindowAdapter class MyFrame extends JFrame, WindowAdapter { // Error! 내부수신자또는익명의내부수신자로실현!

MouseEvent MouseEvent 마우스를움직이거나클릭할때발생 수신자 (1) abstract class MouseListener { abstract void mousepressed(mouseevent e); abstract void mousereleased(mouseevent e); abstract void mouseclicked(mouseevent e); abstract void mouseentered(mouseevent e); abstract void mouseexited(mouseevent e); 수신자 (1) 등록하기 void addmouselistener(mouselistener listener)

MouseEvent 수신자의구현 abstract class MouseListener { abstract void mousepressed(mouseevent e); abstract void mousereleased(mouseevent e); abstract void mouseclicked(mouseevent e); abstract void mouseentered(mouseevent e); abstract void mouseexited(mouseevent e); 메소드선언만있을뿐코드가없다 (interface) 코드구현 (implement) 하기 class MyListener implements MouseListener { public void mouseclicked(mouseevent e) { ( 코드 ) ( 이하생략 )

MouseEvent MouseEvent Pressed / Released / Clicked / Entered / Exited 예제 : 패널에점찍기

MouseListener vs. MouseAdapter MyListener MouseListener 를 implement 하든지, (5 개의메소드모두 ) MouseAdapter 를상속받든지 ( 필요한메소드만치환 ) class MyListener implements MouseListener { 5 가지메소드모두코드구현 또는, class MyListener extends MouseAdapter { 필요한메소드만치환

MouseEvent 수신자 (2) 개별공부 abstract class MouseMotionListener { abstract void mousedragged(mouseevent e); abstract void mousemoved(mouseevent e); 수신자 (2) 등록하기 void addmousemotionlistener(mousemotionlistener listener) 수신자의구현 class MyListener implements MouseMotionListener { ( 코드 )

메뉴 메뉴관련클래스 JMenuBar: 메뉴바 JMenu: 메뉴 JMenuItem: 메뉴항목

메뉴 JMenuBar 생성자 : JMenuBar() 메뉴바에메뉴붙이기 : JMenuBar.add(JMenu menu) 프레임에메뉴바붙이기 : JFrame.setJMenuBar(JMenuBar mb) JMenu 생성자 : JMenu(String name) 메뉴에메뉴항목붙이기 : JMenu.add(JMenuItem item) 메뉴에구분선붙이기 : JMenu.addSeparator()

메뉴 JMenuItem 생성자 : JMenuItem(String name) 메뉴항목은 ActionEvent 를발생시킨다. 예제 void JMenuItem.addActionListener(ActionListener)