Java-12강

2010년 1월 8일 12강

Event Model
What is an Event?
  • Events – Objects that describe what happened.
  • Events Source – The generator of an event
  • Events handlers – A method that receives an event object, deciphers it, and processes the user’s interaction
  • Events Listener

이벤트 객체 – 클래스

이벤트 리스너 – 인터페이스
이벤트 핸들러 – 메소드

Even Adapter

class

Exceptions and Assertions

assertions은 개발자용, 안씀, 툴이 없는 환경에서 디버깅을 위해 사용, 이클립스에 디버깅 기능을 사용하므로 필요없다.
exception은 사용자용, 예외처리,
The Exception class defines mild error conditions that your program encounters.
The Error class defines  serious error conditions.

checked exception

General Exception
try-catch 반드시 써야함

unchecked exception

RuntimeException, error
try-catch 써도되고 안써도되고

Throwable class

JSP에서 exception 객체는 Throwable class.
  • catch하는 방법
  • exception 던지는 방법
  • exception 선언하는 방법

Throwing Exceptions

  • Throw an appropriate exception
  • give the exception a meaningful message
exception을 개발자가 의도적으로 발생시킬 때
“throw new 예외”

throws

메소드 안에서 예외 사용을 알림
access modifier 일반 modifier 리턴타입 이름() throws 예외이름{}

Printing information about exceptions

- The printStackTrace() method
returns a detailed message string about the exception
- The toString() method
returns a detailed message string about the exception

The finally Statement

try-catch-finally
try-finally
  • The finally statement defines a block of code that always executes, regardless of whether an exception was caught.
  • the catch block may be omitted when the finally clause is used.

Creating your own Exception

  1. 내가 만든 exception의 부모가 checked exception or unchecked exception 될지 고려.
  2. 메시지 처리를 어떻게 할건지..

Assertions

툴없이 디버깅을..
assert logical_expression;
assert logical_expression : message;
조건에 안맞으면 assertion 에러가 발생
command option
>java -ea 클래스명
하면 assertion 검사.

Java Graphics

JFC (Java Foundation Class)
  1. AWL
  2. Swing
  3. Drag&Drop
  4. Accessibility
  5. Java 2D
자바 그래픽은 생산성이 떨어짐.
요즘은
flex(client) + Java(server)
Comment are closed.