Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Color;

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

public class Main extends JFrame {
    public Main() {
        super("");
        setSize(570, 400);
        getContentPane().setBackground(new Color(244, 232, 152));

        getLayeredPane().setOpaque(true);

        JButton[] frames = new JButton[5];
        for (int i = 0; i < 5; i++) {
            frames[i] = new JButton("InnerFrame " + i);
            frames[i].setBounds(50 + i * 20, 50 + i * 20, 200, 200);
            getLayeredPane().add(frames[i]);
        }
        super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
    }

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