001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016:
017: package org.columba.calendar.ui.list;
018:
019: import java.awt.Dimension;
020:
021: import javax.swing.JCheckBox;
022: import javax.swing.JTable;
023: import javax.swing.table.DefaultTableColumnModel;
024: import javax.swing.table.TableCellRenderer;
025: import javax.swing.table.TableColumn;
026: import javax.swing.table.TableModel;
027:
028: /**
029: *
030: *
031: * @author fdietz
032: */
033:
034: public class CheckableList extends JTable {
035:
036: // private CheckableItemListTableModel model;
037:
038: public CheckableList() {
039: super ();
040:
041: // do not show header
042: setTableHeader(null);
043:
044: // no grid lines
045: setShowGrid(false);
046:
047: CheckableItemListTableModel model = new CheckableItemListTableModel();
048:
049: super .setModel(model);
050:
051: setRowHeight((int) new JCheckBox("test").getPreferredSize()
052: .getHeight() + 3);
053:
054: }
055:
056: public void setOptionsCellRenderer(TableCellRenderer renderer) {
057:
058: setDefaultRenderer(String.class, renderer);
059:
060: }
061:
062: private void initColumns() {
063: DefaultTableColumnModel model = new DefaultTableColumnModel();
064:
065: TableColumn tc = new TableColumn(0);
066: tc.setIdentifier("Boolean");
067: tc.setMaxWidth(21);
068: tc.setCellEditor(new CheckableListEditor());
069: tc.setCellRenderer(new DefaultBooleanRenderer());
070:
071: model.addColumn(tc);
072:
073: tc = new TableColumn(1);
074: tc.setIdentifier("String");
075: tc.setCellRenderer(new DefaultStringRenderer());
076: model.addColumn(tc);
077:
078: setColumnModel(model);
079:
080: // setIntercellSpacing(new Dimension(2, 2));
081:
082: // setRowMargin(5);
083:
084: }
085:
086: /**
087: * @see javax.swing.JTable#setModel(javax.swing.table.TableModel)
088: * @overwrite
089: */
090: public void setModel(TableModel model) {
091:
092: super .setModel(model);
093:
094: initColumns();
095:
096: setIntercellSpacing(new Dimension(0, 0));
097: }
098:
099: // public CalendarItem getSelected() {
100: // int row = getSelectedRow();
101: //
102: // return ((CheckableItemListTableModel) getModel()).getElement(row);
103: // }
104:
105: }
|