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(5, 40);
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), 0, 0, 1, 1);
add(toPerson, 1, 0, 3, 1);
add(new Label("³» ¿ë: ", Label.RIGHT), 0, 1, 1, 1);
add(body, 1, 1, 3, 1);
add(new Label("÷ºÎ ÆÄÀÏ: ", Label.RIGHT), 0, 2, 1, 1);
add(file, 1, 2, 2, 1);
add(new Button("ã¾Æº¸±â"),3,2,1,1);
add(new Button("Send"), 0, 3, 4, 1);
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(400, 200);
f.setVisible(true);
}
}
C:\JavaExample\13>javac GridBagLayoutTest.java
C:\JavaExample\13>java GridBagLayoutTest
GridbagLayout°ü¸®ÀÚ´Â GridLayout°ü¸®ÀÚ¿Í ºñ½ÁÇÏÁö¸¸, ´õ º¹ÀâÇÏ°í ´Ù¾çÇÑ ÇüÅÂÀÇ LayoutÀ» µðÀÚÀÎÇÒ ¶§ »ç¿ëÇÑ´Ù.
jabookÀúÀÚ¸íÇÔ |
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå ÀÛ¼ºÀÚ:Àںϸâ¹ö ±è´ë¼º |