Java Reference
In-Depth Information
26. // Overriding some methods:
27.
public Class getColumnClass( int c){
28.
return ( getValueAt(0,c).getClass() );
29.
}
30.
31.
public String getColumnName( int c){
32.
return ("Col "+c);
33.
}
34. }
File: its/Tables/MultiplicationTableFrame.java
1. package its.Tables;
2.
3. import its.SimpleFrame.SimpleFrame;
4. import javax.swing.JScrollPane;
5. import javax.swing.JTable;
6.
7. public class MultiplicationTableFrame extends SimpleFrame {
8.
9.
public MultiplicationTableFrame( int r, int c) {
10.
MultiplicationTableModel multModel = new MultiplicationTableModel(r,c);
11.
JTable multTable = new JTable(multModel);
12.
multTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
13.
JScrollPane scrollPane = new JScrollPane(multTable);
14.
this .setSize(350,250);
15.
this .getContentPane().add(scrollPane);
16.
}
17.
18.
public static void main(String[] args) {
19.
MultiplicationTableFrame mtf30 =
20.
new MultiplicationTableFrame(30,30);
21.
mtf30.showIt("Multiplication Table");
22.
}
23. }
16.3.3
Editable tables
In this section we show how different objects are used in different columns and
how the content of table cells can be interactively changed by the user.
The table is an order form where the user can order some products. In our
example three products are available: circles, triangles and rectangles. The ta-
ble has five columns which contain the product's name, a picture of the product,
Search WWH ::




Custom Search