February 2000
Intermediate to advanced
352 pages
6h 31m
English
The JTable class is much like the JList class in that you can very easily program it to do simple things. Similarly, to do more sophisticated things, you can create a class derived from the AbstractTableModel class to hold your data.
In the simplest program, you can create a rectangular array of objects and use it in the constructor for the JTable. You can also include an array of strings to be used as column labels for the table.
public class SimpleTable extends JxFrame { public SimpleTable() { super("Simple table"); JPanel jp = new JPanel(); getContentPane().add(jp); Object[] [] musicData = { {"Tschaikovsky", "1812 Overture", new Boolean(true)}, {"Stravinsky", "Le Sacre", new Boolean(true)} ...Read now
Unlock full access