Java tutorial
import java.awt.BorderLayout; import java.awt.Container; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; public class Main { public static void main(String[] args) { new Test().setVisible(true); } } class Test extends JFrame { String[] name = { "Name", "grade" }; Object[][] cells = { { "A", "B" }, { "C", "D" }, { "E", "F" } }; public Test() { setSize(500, 210); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable tabell = new JTable(cells, name); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(new JScrollPane(tabell), BorderLayout.CENTER); } }