¼Ò¼³ java.awt ¼Ò½ºÄڵ堠Layout Manager  GridbagLayout°ü¸®ÀÚ  

GridbagLayoutÀ» º¸¿©ÁÖ´Â ¿¹Á¦

GridbagLayoutTest.java

import java.awt.*; 
public class GridBagLayoutTest extends 
Frame {
   TextField toPerson, file;
   TextArea body;
   GridBagLayout gbl;
   GridBagConstraints gbc;
   
public 
GridBagLayoutTest() {
      toPerson = 
new TextField(40
);
      file = 
new TextField(30
);
      body = 
new TextArea(540
);
      gbl = 
new 
GridBagLayout();
      gbc = 
new 
GridBagConstraints();
      setLayout(gbl);
      gbc.fill = GridBagConstraints.BOTH;
      gbc.weightx = 
1.0
;
      gbc.weighty = 
1.0
;
      add(
new Label("¹Þ´Â »ç¶÷: ", Label.RIGHT), 0011
);
      add(toPerson, 
1031
);
      add(
new Label("³» ¿ë: ", Label.RIGHT), 0111
);
      add(body, 
1131
);
      add(
new Label("÷ºÎ ÆÄÀÏ: ", Label.RIGHT), 0211
);
      add(file, 
1221
);
      add(
new Button("ã¾Æº¸±â"),3,2,1,1
);
      add(
new Button("Send"), 0341
);
      pack();  
   }
   
private void add(Component c, int x, int y, int w, int 
h) {
      gbc.gridx = x;
      gbc.gridy = y;
      gbc.gridwidth  = w;
      gbc.gridheight = h;
      gbl.setConstraints(c, gbc);
      add(c);
   }
   
public static void 
main(String[] args) {
      GridBagLayoutTest f = 
new 
GridBagLayoutTest();
      f.setTitle(
"GridBagLayout"
);
      f.setSize(
400200
);
      f.setVisible(
true
);
   }
}

C:\JavaExample\13>javac GridBagLayoutTest.java
C:\JavaExample\13>java GridBagLayoutTest

GridbagLayout°ü¸®ÀÚ´Â GridLayout°ü¸®ÀÚ¿Í ºñ½ÁÇÏÁö¸¸, ´õ º¹ÀâÇÏ°í ´Ù¾çÇÑ ÇüÅÂÀÇ LayoutÀ» µðÀÚÀÎÇÒ ¶§ »ç¿ëÇÑ´Ù.



jabookÀúÀÚ¸íÇÔ
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå
ÀÛ¼ºÀÚ:Àںϸâ¹ö ±è´ë¼º