본문 바로가기
Dev/JAVA

[JAVA] 레이블 생성하기

by E.Clone 2016. 8. 8.



LableT.java


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.awt.*;
import java.awt.event.*;
 
public class LableT{
    
    private Frame f;
    private Label l1,l2,l3;
    
    public LableT(){
        f=new Frame("Lable Test");
        
        l1=new Label();
        l2=new Label("Number");
        l3=new Label("Name",Label.RIGHT);
        
        f.addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e){
                System.exit(0);
            }
        });
        l1.setBackground(Color.red);
        l2.setBackground(Color.yellow);
        l3.setBackground(Color.green);
        
        l1.setText("senmon");
        l2.setAlignment(Label.CENTER);
        
        System.out.println("Text of lb2 : "+l2.getText());
        System.out.println("Alignment of lb3 : "+l3.getAlignment());
        
        f.add(l1,"North");
        f.add(l2, "Center");
        f.add(l3, "South");
        
        f.setSize(300200);
        f.setVisible(true);
    }
    
    public static void main(String[] args){
        LableT lt = new LableT();
    }
}
cs



<실행 결과>



반응형