package com.java.myapp;
import java.awt.EventQueue;
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
public class MyForm extends JFrame {
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
MyForm frame = new MyForm();
frame.setVisible(true);
}
});
}
/**
* Create the frame.
*/
public MyForm() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 457, 173);
setTitle("ThaiCreate.Com GUI Tutorial");
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
getContentPane().setLayout(gridBagLayout);
JButton btn1 = new JButton("Button 1");
GridBagConstraints gbc_btn1 = new GridBagConstraints();
gbc_btn1.insets = new Insets(0, 0, 5, 5);
gbc_btn1.gridx = 0;
gbc_btn1.gridy = 0;
getContentPane().add(btn1, gbc_btn1);
JButton btn2 = new JButton("Button 2");
GridBagConstraints gbc_btn2 = new GridBagConstraints();
gbc_btn2.insets = new Insets(0, 0, 5, 5);
gbc_btn2.gridx = 1;
gbc_btn2.gridy = 1;
getContentPane().add(btn2, gbc_btn2);
JButton btn3 = new JButton("Button 3");
GridBagConstraints gbc_btn3 = new GridBagConstraints();
gbc_btn3.insets = new Insets(0, 0, 5, 0);
gbc_btn3.gridx = 3;
gbc_btn3.gridy = 1;
getContentPane().add(btn3, gbc_btn3);
JButton btn4 = new JButton("Button 4");
GridBagConstraints gbc_btn4 = new GridBagConstraints();
gbc_btn4.insets = new Insets(0, 0, 0, 5);
gbc_btn4.gridx = 2;
gbc_btn4.gridy = 2;
getContentPane().add(btn4, gbc_btn4);
}
}