1 7 8 package org.jdesktop.swing; 9 10 import java.util.Vector ; 11 12 import javax.swing.JList ; 13 import javax.swing.ListModel ; 14 15 import org.jdesktop.swing.decorator.ComponentAdapter; 16 import org.jdesktop.swing.decorator.FilterPipeline; 17 import org.jdesktop.swing.decorator.Highlighter; 18 import org.jdesktop.swing.decorator.HighlighterPipeline; 19 20 25 public class JXList extends JList { 26 30 protected FilterPipeline filters = null; 31 protected HighlighterPipeline highlighters = null; 32 33 private final ComponentAdapter dataAdapter = new ListAdapter(this); 35 36 public JXList() { 37 } 38 39 public JXList(ListModel dataModel) { 40 super(dataModel); 41 } 42 43 public JXList(Object [] listData) { 44 super(listData); 45 } 46 47 public JXList(Vector listData) { 48 super(listData); 49 } 50 51 public FilterPipeline getFilters() { 52 return filters; 53 } 54 55 public void setFilters(FilterPipeline pipeline) { 56 60 filters = pipeline; 61 } 62 63 public HighlighterPipeline getHighlighters() { 64 return highlighters; 65 } 66 67 public void setHighlighters(HighlighterPipeline pipeline) { 68 highlighters = pipeline; 69 } 70 71 protected ComponentAdapter getComponentAdapter() { 72 return dataAdapter; 74 } 75 76 77 static class ListAdapter extends ComponentAdapter { 78 private final JList list; 79 80 86 public ListAdapter(JList component) { 87 super(component); 88 list = component; 89 } 90 91 96 public JList getList() { 97 return list; 98 } 99 100 103 public boolean hasFocus() { 104 105 return list.isFocusOwner() && (row == list.getLeadSelectionIndex()); 106 } 107 108 public int getRowCount() { 109 return list.getModel().getSize(); 110 } 111 112 115 public Object getValueAt(int row, int column) { 116 return list.getModel().getElementAt(row); 117 } 118 119 public Object getFilteredValueAt(int row, int column) { 120 121 throw new UnsupportedOperationException ( 122 "Method getFilteredValueAt() not yet implemented."); 123 } 124 125 public void setValueAt(Object aValue, int row, int column) { 126 127 throw new UnsupportedOperationException ( 128 "Method getFilteredValueAt() not yet implemented."); 129 } 130 131 public boolean isCellEditable(int row, int column) { 132 133 return false; 134 } 135 136 139 public boolean isSelected() { 140 141 return list.isSelectedIndex(row); 142 } 143 144 } 145 } 146 | Popular Tags |