Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static void main(String[] args) {
        String subject[] = { "Math", " English", "SQL", "   java", "  c ", " c++ ", " cobol ", "this is a test" };
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JList<String> list = new JList<String>(subject);
        JScrollPane s = new JScrollPane(list);
        s.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        s.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        f.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
        f.add(s);
        f.setSize(300, 300);
        f.setVisible(true);
    }
}