import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
public class Jtabella extends JPanel{
private JTable tab;
public Jtabella(){
String [] colum = {"Nome", "Cognome"};
Object[][] cells = {{"0,0","0,1","0,2"}, {"1,0","1,1","1,2"}};
tab = new JTable(cells, colum);
JScrollPane pan = new JScrollPane();
pan.add(tab);
add(pan);
}
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(new Dimension(400,400));
Jtabella t = new Jtabella();
frame.add(t);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.setVisible(true);
}
}