Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Container;
import java.awt.FlowLayout;

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

public class Main {
    JFrame f = new JFrame();
    Container c;
    JButton btn;
    JTextField tf;

    public Main() {
        f.setBounds(50, 50, 300, 300);

        c = f.getContentPane();
        c.setLayout(new FlowLayout());

        btn = new JButton("OK");
        tf = new JTextField(20);

        c.add(btn);
        c.add(tf);

        f.setVisible(true);
        f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
    }

    public static void main(String[] val) {
        new Main();
    }
}