MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JSlider;
import javax.swing.JTextField;

public class MainClass extends JFrame {

    public MainClass() {
        Box box = new Box(BoxLayout.Y_AXIS);
        box.add(new JButton("Test button"));
        box.add(new JSlider());
        box.add(new JTextField("Text field with some text", 20));
        box.add(new JButton("Another, bigger button"));

        getContentPane().add(box);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        pack();
    }

    public static void main(String[] args) {
        MainClass ex2 = new MainClass();
        ex2.setVisible(true);
    }
}