1 30 package com.genimen.djeneric.ui; 31 32 import javax.swing.JComponent ; 33 import javax.swing.JTextField ; 34 import javax.swing.table.DefaultTableCellRenderer ; 35 import javax.swing.table.TableCellEditor ; 36 import javax.swing.table.TableCellRenderer ; 37 38 public class DjModelColumn 39 { 40 String _title; 41 int _dspWidth; 42 boolean _editable; 43 boolean _visible; 44 TableCellRenderer _renderer; 45 TableCellEditor _editor; 46 47 public DjModelColumn(String title, int width, String tooltip, TableCellRenderer renderer, TableCellEditor editor, 48 boolean alignLeft) 49 { 50 _title = title; 51 _dspWidth = width; 52 _renderer = renderer; 53 if (!alignLeft && (_renderer instanceof DefaultTableCellRenderer )) 54 { 55 DefaultTableCellRenderer r = (DefaultTableCellRenderer ) _renderer; 56 r.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT); 57 } 58 setToolTipText(tooltip); 59 60 _editor = editor; 61 _editable = true; 62 } 63 64 public DjModelColumn(String title, int width, String tooltip, TableCellRenderer renderer, TableCellEditor editor) 65 { 66 this(title, width, tooltip, renderer, editor, true); 67 } 68 69 public DjModelColumn(String title, int width, String tooltip) 70 { 71 this(title, width, tooltip, new DefaultTableCellRenderer (), new DjCellEditor(new JTextField ()), true); 72 } 73 74 public DjModelColumn(String title, int width, String tooltip, TableCellRenderer renderer) 75 { 76 this(title, width, tooltip, renderer, new DjCellEditor(new JTextField ()), true); 77 } 78 79 public DjModelColumn(String title, int width, String tooltip, boolean alignLeft) 80 { 81 this(title, width, tooltip, new DefaultTableCellRenderer (), new DjCellEditor(new JTextField ()), alignLeft); 82 } 83 84 public TableCellRenderer getCellRenderer() 85 { 86 return _renderer; 87 } 88 89 public TableCellEditor getCellEditor() 90 { 91 return _editor; 92 } 93 94 public void setToolTipText(String tooltip) 95 { 96 if (tooltip != null && tooltip.trim().length() > 0 && (_renderer instanceof JComponent )) 97 { 98 JComponent r = (JComponent ) _renderer; 99 r.setToolTipText(tooltip); 100 } 101 } 102 } | Popular Tags |