Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class Main {
    public static void main(String[] args) {

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        JPanel panel = new JPanel();
        Container c = frame.getContentPane();
        panel.setSize(100, 100);
        panel.setLayout(new GridLayout(1000, 1));
        for (int i = 0; i < 1000; i++)
            panel.add(new JLabel("JLabel " + i));

        JScrollPane jsp = new JScrollPane(panel);
        c.add(jsp);
        frame.setSize(100, 100);
        frame.setVisible(true);

    }
}