Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Main {
    public static void main(String[] args) {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(getPanel());
        f.pack();
        f.setVisible(true);
    }

    private static JPanel getPanel() {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(new JLabel("Top"), BorderLayout.NORTH);
        panel.add(new JLabel("Center"), BorderLayout.CENTER);
        panel.add(new JLabel("Bottom"), BorderLayout.SOUTH);
        panel.setPreferredSize(new Dimension(400, 300));
        return panel;
    }
}