Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Vector;

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

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Vector<String> data = new Vector<String>();
        for (int i = 1; i < 100; i++) {
            data.add("Entry " + i);
        }
        JList<String> list = new JList<>(data);
        list.setVisibleRowCount(8);
        JScrollPane scrollPane = new JScrollPane(list);
        frame.add(scrollPane);
        frame.pack();
        frame.setVisible(true);
    }
}