package test;
import java.awt.Button;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.*;
public class test
{
JFrame frame;
JPanel panel;
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
void init(String title)
{
frame = new JFrame(title);
try
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception e){}
frame.setSize(500,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
void build()
{
JButton b1 = new JButton("b1");
JButton b2 = new JButton("b2");
panel = new JPanel();
panel.setLayout(gridbag);
constraints.gridx = 1;
constraints.gridy = 2;
panel.add(b1,constraints);
constraints.gridx = 1;
constraints.gridy = 3;
panel.add(b2,constraints);
constraints.gridx = 7;
constraints.gridy = 5;
panel.add(new JButton("b3"),constraints);
constraints.gridx = 7;
constraints.gridy = 6;
panel.add(new JButton("b4"),constraints);
frame.getContentPane().setLayout(gridbag);
constraints.gridx = 0;
constraints.gridy = 0;
frame.getContentPane().add(panel,constraints);
}
void cleanUp()
{
//frame.setVisible(true);
frame.show();
}
public static void main(String[] args)
{
test t = new test();
t.init("yinxing");
t.build();
t.cleanUp();
}
}