Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Container;

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

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container contentPane = frame.getContentPane();
        contentPane.setLayout(null);

        JButton b1 = new JButton("Button");
        JButton b2 = new JButton("2");
        contentPane.add(b1);
        contentPane.add(b2);

        b1.setBounds(10, 10, 100, 20);
        b2.setBounds(120, 10, 150, 40);

        frame.setBounds(0, 0, 350, 100);
        frame.setVisible(true);
    }
}