Hi everyone,
can anyone tell me how to change the column (header or title ) name (a,b,c,d) in my code below to my own creation, say: name, age, gpa, address, color, food ???
also, any (design) idea of how to insert/update this "matrics'" content into a database (so later the same information can be retrieved in the right order the user inserted them???)
Thanks
Ppr
import java.awt.*;
import javax.swing.table.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class MySimpleJtable extends JFrame
{
JTable table;
DefaultTableModel tableModel;
public MySimpleJtable()
{
table = new JTable(10, 5);
tableModel = (DefaultTableModel)table.getModel();
table.setPreferredScrollableViewportSize(table.getPreferredSize());
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add(scrollPane);
}
public static void main(
String[] args)
{
MySimpleJtable frame = new MySimpleJtable();
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}