LabelComponent를 사용하여 문자열이나 이미지를 나타내면 일단은 사용자에 의해 수정할 수 없다. LabelComponent는 사용자에게 보여줄 때 문자열가 이미지를 포맷팅해서 출력해 주기 때문이다.
LabelComponent 클래스의 주요 생성자 |
- public LabelComponent() LabelComponent를 생성한다. |
- public LabelComponent(String str) 주어진 문자열로 LabelComponent를 생성한다. |
- public LabelComponent(String str, Image img) 주어진 문자열과 이미지로 LabelComponent를 생성한다. |
LabelComponent 클래스의 주요 메소드 |
- public void setLabel(String str) 내부 문자열을 주어진 문자열 값으로 지정한다. |
- public void setImage(Image img) 내부 이미지를 주어진 이미지로 지정한다. |
- public String getLabel() 내부 문자열을 가져온다. |
- public Image getImage() 내부 이미지를 가져온다. |
- public void setFont(Font font) 폰트를 지정한다. |
- public Font getFont() 폰트를 얻어온다. |
- public void setLayout(int layout) 레벨의 정렬 형태를 지정한다. |
라벨 컴포넌트에 문자열과 이미지를 추가하는 예제를 보도록 하자
import java.io.IOException;
import org.kwis.msp.lcdui.*;
import org.kwis.msp.lwc.*;
public class wipiTest extends Jlet{
ShellComponent sc= new ShellComponent();
FormComponent fc= new FormComponent();
LabelComponent label1= new LabelComponent();
LabelComponent label2= new LabelComponent();
LabelComponent label3= new LabelComponent("이미지");
public void startApp(String args[]){
labelSet1();
labelSet2();
labelSet3();
sc.addComponent(fc);
sc.show();
}
public void pauseApp(){}
public void resumeApp(){}
public void destroyApp(boolean b){}
public void labelSet1(){
label1.setLabel("라벨 컴포넌트");
fc.addComponent(label1);
}
public void labelSet2(){
label2.setLabel(label1.getLabel());
fc.addComponent(label2);
}
public void labelSet3(){
try{
Image img= Image.createImage("m.gif");
label3.setImage(img);
}catch(IOException ie){}
fc.addComponent(label3);
fc.setGab(10);
}
};
출력은 다음과 같다.
'Computer > Jlet' 카테고리의 다른 글
[15] 컴포넌트 - (5)ButtonComponent (0) | 2006.08.12 |
---|---|
[14] 컴포넌트 - (4)ListComponent/ListItemComponent (0) | 2006.08.12 |
[12] 컴포넌트 - (2)ShellComponent/FormComponent (0) | 2006.08.11 |
[11] 컴포넌트 - (1)ContainerComponent (0) | 2006.08.11 |
[10] 컴포넌트 (0) | 2006.08.11 |