UseGridBag2(LAB7)
import javax.swing.*;
import java.awt.*;
class UseGridBag2 extends JFrame{
public UseGridBag2(String title){
super(title);
GridBagLayout gb=new GridBagLayout();
GridBagConstraints gc=new GridBagConstraints();
Container c=getContentPane();
c.setLayout(gb);
gc.gridx=0; gc.gridy=0;
c.add(new JButton("Button 1"),gc);
gc.gridx=1;gc.gridy=1;
c.add(new JButton("Button2"),gc);
gc.gridx=2; gc.gridy=2;
c.add(new JButton("Button3"),gc);
}
public static void main(String[]args){
UseGridBag2 f=new UseGridBag2("Use GridBag2");
f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
f.pack();
f.show();
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น