Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import javax.swing.*;
- public class Main{
- public static void main(String[] args){
- JFrame fr = new JFrame("test");
- MyPanel p1 = new MyPanel();
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = new Insets(5, 5, 5, 5);
- gbc.fill = GridBagConstraints.HORIZONTAL;
- p1.setLayout(new GridBagLayout());
- gbc.gridx = 0;
- gbc.gridy = 0;
- p1.add(new JButton("btn1"), gbc);
- gbc.gridx = 1;
- gbc.gridy = 0;
- p1.add(new JButton("btn1"), gbc);
- gbc.gridx = 2;
- gbc.gridy = 0;
- p1.add(new JButton("btn1"), gbc);
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.gridwidth = 2;
- p1.add(new JButton("btn2"), gbc);
- gbc.gridwidth = 1;
- gbc.gridx = 0;
- gbc.gridy = 2;
- p1.add(new JButton("btn3"), gbc);
- fr.setContentPane(p1);
- fr.setSize(500, 500);
- fr.setVisible(true);
- fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement