본문 바로가기
Dev/JAVA

[JAVA] 프레임에 버튼 배치하기-3-(FlowLayout)

by E.Clone 2016. 8. 8.


FlowLayout1.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
import java.awt.*;
import java.awt.event.*;
 
public class FlowLayout1 {
    private Frame f;
    private Button b1,b2,b3,b4,b5;
    
    public FlowLayout1(){
        f=new Frame("FlowLayout Test");
        
        b1 = new Button("btn1");
        b2 = new Button("btn2");
        b3 = new Button("btn3");
        b4 = new Button("btn4");
        b5 = new Button("btn5");
        
        f.addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e){
                System.exit(0);
            }
        });
        
        Panel p = new Panel();
        
        p.add(b1);
        p.add(b2);
        p.add(b3);
        p.add(b4);
        p.add(b5);
        
        f.add(p, "Center");
        f.setSize(500200);
        f.setVisible(true);
        
    }
    
    public static void main(String[] args){
        FlowLayout1 ft = new FlowLayout1();
    }
}
cs



<실행결과>


반응형