1 7 package javax.swing.event; 8 9 import javax.swing.RowSorter ; 10 11 26 public class RowSorterEvent extends java.util.EventObject { 27 private Type type; 28 private int[] oldViewToModel; 29 30 35 public enum Type { 36 39 SORT_ORDER_CHANGED, 40 41 45 SORTED 46 } 47 48 56 public RowSorterEvent(RowSorter source) { 57 this(source, Type.SORT_ORDER_CHANGED, null); 58 } 59 60 70 public RowSorterEvent(RowSorter source, Type type, 71 int[] previousRowIndexToModel) { 72 super(source); 73 if (type == null) { 74 throw new IllegalArgumentException ("type must be non-null"); 75 } 76 this.type = type; 77 this.oldViewToModel = previousRowIndexToModel; 78 } 79 80 85 public RowSorter getSource() { 86 return (RowSorter )super.getSource(); 87 } 88 89 94 public Type getType() { 95 return type; 96 } 97 98 109 public int convertPreviousRowIndexToModel(int index) { 110 if (oldViewToModel != null && index >= 0 && 111 index < oldViewToModel.length) { 112 return oldViewToModel[index]; 113 } 114 return -1; 115 } 116 117 124 public int getPreviousRowCount() { 125 return (oldViewToModel == null) ? 0 : oldViewToModel.length; 126 } 127 } 128 | Popular Tags |