![]() |
![]() |
![]() |
![]() |
![]() |
|
Next, the
DefaultListSelectionModel allows row selections; without
connected listeners to take note of selections, however, users will be
confused. Therefore, you shut off selection. All you need to do is to
call the setRowSelectionAllowed method defined in the
JTable class. You learn about selection and listeners later, in
Segment 1006.
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
public class RatingTable extends JTable {
public RatingTable (Vector rows, Vector columns) {
super(new RatingTableModel(rows, columns));
TableColumnModel model = getColumnModel();
for (int i = 0; i < columns.size(); ++i) {
TableColumn column = model.getColumn(i);
if (i == 0) {
column.setPreferredWidth(417);
}
else {
column.setPreferredWidth(83);
}
}
setRowSelectionAllowed(false);
}
}