package java0915_gui; import java.awt.BorderLayout; import java.awt.Button; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; /* * ë ì´ìì(layout) : 컨í ì´ëì ì»´í¬ëí¸ë¥¼ ì°ê²°í ì ìëë¡ íë©´ë°°ì¹ë¥¼ ì¤ê³í´ì£¼ë 기ë¥ì´ë¤. * ë ì´ììê´ë¦¬ì(Layout Manager) : 컨í ì´ëì ì»´í¬ëí¸ë¥¼ ì ì íê² ë°°ì¹í ì ìëë¡ ìëì ì¼ë¡ ì¼ì ë´ë¹íê³ ìë¤. * ë ì´ìì ì¢ ë¥ * 1 BorderLayout : North, South, East, West, Center5ê°ì ììì¼ë¡ ì´ë£¨ì´ì§ ë ì´ììì´ë¤. * 2 FlowLayout : ì¶ê°ëë ì»´í¬ëí¸ì ë°ë¼ ì¼ìª½ìì ì¤ë¥¸ìª½ì¼ë¡ ì°ê²°íë¤. * 3 GridLayout : í ì´ë¸ì²ë¼ íê³¼ ì´ë¡ ëëì´ ì»´í¬ëí¸ë¥¼ ë°°ì¹íë¤. * 4 GridBagLayout : ì»´í¬ëí¸ì í¬ê¸°ë¥¼ ë¤ë¥´ê² í´ì ë°°ì¹í ë ì¬ì©íë¤. * 5 CardLayout : ì¬ë¬ íë©´ì ì¬ë¼ì´ëì²ë¼ ë°ê¿ê°ë©° ë³´ì¬ì¤ ì ìë¤. * * 컨í ì´ëë³ ê¸°ë³¸ë ì´ìì * 1 FlowLayout - Panel, Applet * 2 BorderLayout - Window, Frame, Dialog */ class LayoutTest extends Frame { Button northBtn, centerBtn, southBtn, eastBtn, westBtn; public LayoutTest() { northBtn = new Button("north"); centerBtn = new Button("center"); southBtn = new Button("south"); eastBtn = new Button("east"); westBtn = new Button("west"); // 컨í ì´ëì ì»´í¬ëí¸ ì°ê²°: add() // 컨í ì´ë.add(ì»´í¬ëí¸) this.add(BorderLayout.NORTH, northBtn); this.add(BorderLayout.CENTER, centerBtn); this.add(BorderLayout.SOUTH, southBtn); this.add("East", eastBtn); // ê¶ì¥íë ë°©ë²ì ìëë ì¬ì©í ìë ìë¤. ì¬ì© ì§ì í ê² this.add(westBtn, BorderLayout.WEST); // ììë ìê´ ìë¤. setSize(500, 400); setVisible(true); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); } } public class Java213_gui { public static void main(String[] args) { new LayoutTest(); } }