3 import javajs.awt.Dimension;
8 public class JTable extends JComponent implements ListSelectionModel, ColumnSelectionModel {
10 private AbstractTableModel tableModel;
11 private BS bsSelectedCells;
12 private BS bsSelectedRows;
14 boolean rowSelectionAllowed;
15 boolean cellSelectionEnabled;
16 Object selectionListener;
18 public JTable(AbstractTableModel tableModel) {
20 this.tableModel = tableModel;
21 this.bsSelectedCells = new BS();
22 this.bsSelectedRows = new BS();
26 public ListSelectionModel getSelectionModel() {
30 public ColumnSelectionModel getColumnModel() {
34 public void setPreferredScrollableViewportSize(Dimension dimension) {
35 this.width = dimension.width;
36 this.height = dimension.height;
39 public void clearSelection() {
40 bsSelectedCells.clearAll();
41 bsSelectedRows.clearAll();
44 public void setRowSelectionAllowed(boolean b) {
45 rowSelectionAllowed = b;
48 public void setRowSelectionInterval(int i, int j) {
49 bsSelectedRows.clearAll();
50 bsSelectedRows.setBits(i, j);
51 bsSelectedCells.clearAll();
54 public void setCellSelectionEnabled(boolean enabled) {
55 cellSelectionEnabled = enabled;
59 * It will be the function of the JavaScript on the
60 * page to do with selectionListener what is desired.
66 public void addListSelectionListener(Object listener) {
67 selectionListener = listener;
71 public TableColumn getColumn(int i) {
72 return tableModel.getColumn(i);
76 public String toHTML() {
78 sb.append("\n<table id='" + id + "_table' class='JTable' >");
79 tableModel.toHTML(sb, id, bsSelectedRows);
80 sb.append("\n</table>\n");