MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.awt.BorderLayout;

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

public class MainClass extends JFrame {

    JScrollPane scrollpane;

    public MainClass() {
        super("JScrollPane Demonstration");
        setSize(300, 200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        String categories[] = { "A", "B", "C", "D", "E", "F" };
        JList list = new JList(categories);
        scrollpane = new JScrollPane(list);

        getContentPane().add(scrollpane, BorderLayout.CENTER);
    }

    public static void main(String args[]) {
        MainClass sl = new MainClass();
        sl.setVisible(true);
    }
}