Java Reference
In-Depth Information
(a)
(b)
Figure 16.4
MultiplicationTableFrame
. (a) The column widths are reduced to fit the
width of the display. As there is a minimum column width (15 pixels on most platforms) this
is not always possible. (b) The automatic resizing is switched off and all columns have their
default width (75 pixels on most platforms)
File:
its/Tables/MultiplicationTableModel.java
package
its.Tables;
1.
2.
3.
import
javax.swing.table.AbstractTableModel;
4.
5.
public class
MultiplicationTableModel
extends
AbstractTableModel{
6.
7.
private int
noOfRows, noOfCols;
8.
public
MultiplicationTableModel(
int
r,
int
c) {
9.
noOfRows = r;
10.
noOfCols = c;
11.
}
12.
13.
//
Implementing the tree abstract methods:
14.
public int
getColumnCount() {
15.
return
(noOfRows);
16.
}
17.
18.
public
Object getValueAt(
int
r,
int
c) {
19.
return
(
new
Integer(r*c));
}
20.
21.
22.
public int
getRowCount() {
return
(noOfRows);
23.
}
24.
25.
Search WWH ::
Custom Search