1 7 8 package org.jdesktop.swing.decorator; 9 10 import javax.swing.JComponent ; 11 12 20 public abstract class ComponentAdapter { 21 public int row = 0; 22 public int column = 0; 23 protected final JComponent target; 24 25 31 public ComponentAdapter(JComponent component) { 32 target = component; 33 } 34 35 public JComponent getComponent() { 36 return target; 37 } 38 39 44 public String getColumnName(int columnIndex) { 45 throw new RuntimeException ("getColumnName() must be overridden by subclass"); 46 } 47 48 53 public int getColumnCount() { 54 return 1; } 56 57 62 public int getRowCount() { 63 return 0; 64 } 65 66 74 public Object getValue() { 75 return getValueAt(row, column); 76 } 77 78 87 public abstract Object getValueAt(int row, int column); 88 public abstract Object getFilteredValueAt(int row, int column); 89 public abstract void setValueAt(Object aValue, int row, int column); 90 91 public abstract boolean isCellEditable(int row, int column); 92 93 100 public abstract boolean hasFocus(); 101 102 109 public abstract boolean isSelected(); 110 111 120 public boolean isExpanded() { 121 return true; } 123 124 133 public boolean isLeaf() { 134 return true; } 136 137 146 public boolean isHierarchical() { 147 return false; } 149 150 160 public int modelToView(int columnIndex) { 161 return columnIndex; } 163 164 174 public int viewToModel(int columnIndex) { 175 return columnIndex; } 177 178 public void refresh() { 179 target.revalidate(); 180 target.repaint(); 181 } 182 } | Popular Tags |