Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        JPanel panel = new JPanel();
        panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Table Title",
                TitledBorder.CENTER, TitledBorder.TOP));

        JTable table = new JTable(3, 3);

        panel.add(new JScrollPane(table));

        frame.add(panel);
        frame.pack();
        frame.setVisible(true);
    }
}