Computer125 [15] 컴포넌트 - (5)ButtonComponent 버튼의 주된 목적은 무엇일까? 버튼이 눌렸는데도 아무런 일이 발생 하지 않는다면 아무런 소용이 없다. 버튼을 누르면 Event가 발생해야 한다. 여기서 Event가 발생한다는 것은 행위자의 행위가 전달루트를 통해서 어떤 일이 발생한다는 것이다. 해당 버튼을 setActionListener(전달루트)를 통해 등록한 후 버튼을 눌렀을 경우의 동작을 action메소드에서 정의하면 된다. action은 인터페이스 ActionListener를 통해 오버라이딩 해야 한다. 잠시 인터페이스 ActionListener에 대해 알아 보자. ActionListener 인터페이스의 클래스 선언부public interface ActionListenerActionListener 인터페이스의 추상 메소드- public void .. 2006. 8. 12. [14] 컴포넌트 - (4)ListComponent/ListItemComponent ListComponent와 ListItemComponent는 부모 클래스도 다르고, 성격도 완전히 다른 클래스이다. 그럼에도 불구하고 이렇게 같이 붂어서 설명하려는 데에는 이유가 있다. 이 둘은 서로 떨어져서는 아무일도 못하기 때문이다. public class ListComponent extends FormComponent public class ListItemComponent extends LabelComponent 선언부에서 알 수 있듯이, 두 컴포넌트는 상속받은 부모 클래스가 다르다. 일단 두 컴포넌트의 상호 관계를 살펴 본 후 각 컴포넌트에 대해 상세히 알아보자. List는 문자 그대로 목록을 나타내는 클래스이다. 앞에서 우리는 Container 계열의 ShellComponent와 FormComp.. 2006. 8. 12. [13] 컴포넌트 - (3)LabelComponent LabelComponent를 사용하여 문자열이나 이미지를 나타내면 일단은 사용자에 의해 수정할 수 없다. LabelComponent는 사용자에게 보여줄 때 문자열가 이미지를 포맷팅해서 출력해 주기 때문이다. LabelComponent 클래스의 주요 생성자- public LabelComponent() LabelComponent를 생성한다.- public LabelComponent(String str) 주어진 문자열로 LabelComponent를 생성한다.- public LabelComponent(String str, Image img) 주어진 문자열과 이미지로 LabelComponent를 생성한다.LabelComponent 클래스의 주요 메소드- public void setLabel(String str) .. 2006. 8. 12. [12] 컴포넌트 - (2)ShellComponent/FormComponent ContainerComponent 클래스를 상속받아 구현한 ShellComponent와 FormComponent는 유사한 점이 많다. 당연히 같은 부모 클래스로 부터 상속을 받았으니 유사한 면도 있을 것이고 다른 성격을 가질 수도 있을 것이다. 그런데 여기서 다른 성격을 가진 이 두 컴포넌트를 굳이 같이 묶어서 설명하려는 이유는 결국 부모인 ContainerComponent의 일을 물려 받았기 때문이다. 즉 ShellComponent 클래스와 FormComponent 클래스는 둘 다 하위의 컴포넌트들을 담는 역할을 한다. 다른 점은 ShellComponent는 단 하나의 자식 컴포넌트를 갖는다는 것이고, FormComponent는 여러 개의 자식 컴포넌트를 갖는다는 것이다. 다음 예를 보면 이해가 쉬울 .. 2006. 8. 11. 이전 1 ··· 24 25 26 27 28 29 30 ··· 32 다음