반응형

* Layout Manager


1. FlowLayout : Panel, Applet의 default Layout manager

     - Component를 왼쪽에서 오른쪽으로 배치

     - Default로 component를 Frame의 중앙에 배치

     - Component의 size는 layout maneger가 결정

     - Layout Manager의 Constructor를 이용하면 Manager의 속성을 변경할 수 있다.


     ex) setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 40))

          Component를 오른쪽에 배치하며, 20은 Component간의 좌우 Gap을 지정하며, 40은

          Component간의 상하 Gap을 지정하는 것이다. 단위는 pixel.


2. BorderLayout : Window, Frame의 default manager

     - Component를 East, West, North, South, Center 다섯군데에 배치

     - f.add(bn, BorderLayout.NORTH)    f.add(bn, NORTH)   둘 다 버튼을 북쪽에 배치

     - 위치를 지정하지 않으면 Center에 겹쳐 나타나게 된다.


3. GridLayout

     - 격자를 만들어 그 위에 Component를 배치

     - Component를 추가하면 왼쪽에서 오른쪽으로, 위쪽에서 아래쪽으로 배치

     - Constructor를 통해 격자의 크기 결정가능.


4. CardLayout

     - 여러장의 카드(Panel로 구성)를 겹쳐놓고 필요에 따라 그 카드를 보여줌


5. GridBagLayout

     - GridLayout과 비슷하나 더 복잡

+ Recent posts