Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

public class Main {

    public static void main(String[] args) {
        int MAX_CELLS = 30;

        DefaultListModel<String> listModel = new DefaultListModel<>();
        JList<String> myList = new JList<>(listModel);
        myList.setVisibleRowCount(8);

        for (int i = 0; i < MAX_CELLS; i++) {
            listModel.addElement("label " + i);
        }

        JTabbedPane jTabbedPane = new JTabbedPane();

        jTabbedPane.add("Test", new JScrollPane(myList));

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(jTabbedPane);
        frame.pack();
        frame.setVisible(true);
    }
}