Java Reference
In-Depth Information
File: its/Tables/OrderTableModel.java
1. package its.Tables;
2.
3. import javax.swing.ImageIcon;
4. import javax.swing.table.AbstractTableModel;
5.
6. public class OrderTableModel extends AbstractTableModel
7. {
8.
private String[] columnNames = {"Product","Picture","Price",
9.
"Quantity","Total"};
10.
private String[] products
= {"Circle","Triangle","Rectangle"};
11.
private String[] imageName
= {"circ.png","tria.png","rect.png"};
12.
private int [] quantities
= {0,0,0};
13.
private double [] prices
= {10.00, 12.00, 12.50};
14.
private static final String Path = "./its/TestData/";
15.
public boolean [] bv= { true , false , true };
16.
17.
public OrderTableModel()
18.
{
19.
}
20.
public int getColumnCount()
21.
{
22.
return (columnNames.length);
23.
}
24.
25.
public int getRowCount()
26.
{
27.
return (products.length+1);
28.
}
29.
30.
public String getColumnName( int c) {
31.
return (columnNames[c]);
32.
}
33.
34.
public Class getColumnClass( int c) {
35.
return getValueAt(0, c).getClass();
36.
}
37.
38.
public Object getValueAt( int r, int c)
39.
{
40.
Object result = new Object();
41.
if (r<products.length) {
42.
switch (c){
43.
case 0: result = products[r]; break ;
44.
case 1: result = new ImageIcon(Path+imageName[r]); break ;
Search WWH ::




Custom Search