Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.BorderLayout;

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

public class Main {

    public static void main(final String args[]) {
        String labels[] = { "A", "B", "C", "D", "E" };
        JFrame frame = new JFrame("Sizing Samples");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JList jlist1 = new JList();
        jlist1.setListData(labels);

        jlist1.setVisibleRowCount(4);
        JScrollPane scrollPane1 = new JScrollPane(jlist1);
        frame.add(scrollPane1, BorderLayout.NORTH);

        ListSelectionListener[] lis = jlist1.getListSelectionListeners();

        frame.setSize(300, 350);
        frame.setVisible(true);
    }
}