Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Color;

import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;

public class Main {
    public static void main(String[] args) {
        Integer[][] data = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
        String[] cols = { "A", "B", "C" };

        JTable table = new JTable(data, cols);

        JTableHeader header = table.getTableHeader();
        header.setBackground(Color.black);
        header.setForeground(Color.yellow);

        JOptionPane.showMessageDialog(null, new JScrollPane(table));
    }
}