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;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;

public class Main {

    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.getContentPane().add(new TabView());
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setMinimumSize(new Dimension(800, 450));
        frame.pack();
        frame.setVisible(true);
    }
}

class TabView extends JPanel {
    JTabbedPane tabbedPane = new JTabbedPane();

    TabView() {
        tabbedPane.addTab("Hello", new JLabel("World"));
        tabbedPane.addTab("Goodbye", new JLabel("Sunshine"));
        setLayout(new BorderLayout());

        tabbedPane.setTabPlacement(JTabbedPane.TOP);
        tabbedPane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
        add(tabbedPane, BorderLayout.CENTER);
    }
}