Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.GridBagLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Main {
    public static void main(String[] argv) throws Exception {
        JFrame frame = new JFrame();
        GridBagLayout gbl = new GridBagLayout();

        frame.setLayout(gbl);
        frame.add(new JButton("1"));
        frame.add(new JButton("2"));

        gbl.layoutContainer(frame);

        gbl.columnWeights = new double[] { 0.0f, 1.0f, 2.0f };
        gbl.rowWeights = new double[] { 0.0f, 1.0f };

        frame.pack();
        frame.setVisible(true);
    }
}