01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.applications.designstudio.primarykeytable;
16:
17: import java.awt.Component;
18:
19: import javax.swing.Icon;
20: import javax.swing.JLabel;
21: import javax.swing.JTable;
22: import javax.swing.table.DefaultTableCellRenderer;
23: import javax.swing.table.TableColumn;
24:
25: /* Primary Key Table */
26:
27: public class PrimaryKeyTable extends JTable {
28: public PrimaryKeyTable(PrimaryKeyTableModel pModel) {
29: super (pModel);
30:
31: setRowHeight(20);
32:
33: TableColumn lFirstColumn = getColumnModel().getColumn(0);
34: lFirstColumn.setMinWidth(20);
35: lFirstColumn.setMaxWidth(20);
36: /*lFirstColumn.setCellRenderer(new DefaultTableCellRenderer()
37: {
38: public Component getTableCellRendererComponent(JTable table,
39: Object value, boolean isSelected, boolean hasFocus,
40: int row, int column)
41: {
42: return super.getTableCellRendererComponent(table, value, false, hasFocus, row, column);
43: }
44: });*/
45:
46: TableColumn lSecondColumn = getColumnModel().getColumn(1);
47: lSecondColumn.setMinWidth(20);
48: lSecondColumn.setMaxWidth(20);
49: lSecondColumn.setCellRenderer(new DefaultTableCellRenderer() {
50: private JLabel mLabel = new JLabel();
51:
52: public Component getTableCellRendererComponent(
53: JTable table, Object value, boolean isSelected,
54: boolean hasFocus, int row, int column) {
55: mLabel.setIcon((Icon) value);
56: return mLabel;
57: }
58: });
59:
60: TableColumn lThirdColumn = getColumnModel().getColumn(2);
61: lThirdColumn.setCellRenderer(new DefaultTableCellRenderer() {
62: public Component getTableCellRendererComponent(
63: JTable table, Object value, boolean isSelected,
64: boolean hasFocus, int row, int column) {
65: return super .getTableCellRendererComponent(table,
66: value, false, false, row, column);
67: }
68: });
69:
70: TableColumn lForthColumn = getColumnModel().getColumn(3);
71: lForthColumn.setCellRenderer(new DefaultTableCellRenderer() {
72: public Component getTableCellRendererComponent(
73: JTable table, Object value, boolean isSelected,
74: boolean hasFocus, int row, int column) {
75: return super .getTableCellRendererComponent(table,
76: value, false, false, row, column);
77: }
78: });
79: }
80: }
|