lang/java
java AWT Label 컴포넌트
C/H
2007. 6. 20. 17:09
[code type=java]
// Labelex1.java
import java.awt.*;
import java.awt.event.*; class LabelEx1
{
Panel p1; //라벨이 붙을 패널
Label label1;
public LabelEx1(){
p1 = new Panel();
label1 = new Label("이것은 라벨입니다.");
p1.add(label1);
}
public Panel getPanel(){
return p1;
}
public static void main(String[] args)
{
LabelEx1 ex1 = new LabelEx1();
Frame f = new Frame("패널 보여주기");
f.add(ex1.getPanel()); f.setSize(200, 200);
f.setVisible(true); //종료버튼
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent w){
System.exit(0);
}
});
}
} /* 분석
-------- label1
-------------------- Panel 객체
------------------------------------------ Frame 객체
*/
[/code]
// Labelex1.java
import java.awt.*;
import java.awt.event.*; class LabelEx1
{
Panel p1; //라벨이 붙을 패널
Label label1;
public LabelEx1(){
p1 = new Panel();
label1 = new Label("이것은 라벨입니다.");
p1.add(label1);
}
public Panel getPanel(){
return p1;
}
public static void main(String[] args)
{
LabelEx1 ex1 = new LabelEx1();
Frame f = new Frame("패널 보여주기");
f.add(ex1.getPanel()); f.setSize(200, 200);
f.setVisible(true); //종료버튼
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent w){
System.exit(0);
}
});
}
} /* 분석
-------- label1
-------------------- Panel 객체
------------------------------------------ Frame 객체
*/
[/code]
반응형