import java.applet.* ; import java.awt.* ; public class demo03d extends Applet { Label label1 = new Label("GridBagLayout") ; TextField tf = new TextField(10) ; Button bt1 = new Button("Button 1") ; Button bt2 = new Button("Button 2") ; Scrollbar sc = new Scrollbar(Scrollbar.HORIZONTAL,50,10,0,100+10) ; GridBagLayout gb = new GridBagLayout() ; GridBagConstraints gc = new GridBagConstraints() ; public void init() { setLayout(gb) ; gc.fill=GridBagConstraints.HORIZONTAL ; gc.gridx=0 ; gc.gridy=0 ; gc.gridwidth=2 ; gc.gridheight=1 ; gb.setConstraints(label1,gc) ; add(label1) ; gc.gridx=2 ; gc.gridy=0 ; gc.gridwidth=3 ; gc.gridheight=1 ; gb.setConstraints(tf,gc) ; add(tf) ; gc.gridx=0 ; gc.gridy=1 ; gc.gridwidth=1 ; gc.gridheight=1 ; gb.setConstraints(bt1,gc) ; add(bt1) ; gc.gridx=1 ; gc.gridy=1 ; gc.gridwidth=4 ; gc.gridheight=1 ; gb.setConstraints(bt2,gc) ; add(bt2) ; gc.gridx=0 ; gc.gridy=2 ; gc.gridwidth=5 ; gc.gridheight=1 ; gb.setConstraints(sc,gc) ; add(sc) ; } }