본문 바로가기
Dev/JAVA

[JAVA] 프레임에 버튼 배치하기-2-

by E.Clone 2016. 8. 8.

ButtonT.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
import java.awt.*;
import java.awt.event.*;
 
public class ButtonT{
    private Frame f;
    private Button b1, b2;
    
    public ButtonT(){
        f=new Frame("Button");
        f.addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e){
                System.exit(0);
            }
        });
        
        b1 = new Button();
        b2 = new Button("Click");
        
        b1.setLabel("Add");
        
        f.add(b1,"North");
        f.add(b2,"Center");
        
        f.setSize(200,100);
        f.setVisible(true);
    }
    public static void main(String[] args){
        ButtonT bt = new ButtonT();
    }
}
cs



<실행화면>


반응형