A JTable to display int, double and String array values. Version 1.1 uses a Timer to coalesce Refresh Table events @author Douglas Brown @author Wolfgang Christian @version 1.1
| 41 | * @version 1.1 |
| 42 | */ |
| 43 | @SuppressWarnings("serial") |
| 44 | public class ArrayTable extends JTable implements ActionListener { |
| 45 | int refreshDelay = 300; // time in ms to delay refresh events |
| 46 | javax.swing.Timer refreshTimer = new javax.swing.Timer(refreshDelay, this); // delay for refreshTable |
| 47 | ArrayTableModel tableModel; |
| 48 | ArrayIndexRenderer indexRenderer = new ArrayIndexRenderer(); |
| 49 | ArrayCellRenderer cellRenderer = new ArrayCellRenderer(); |
| 50 | java.util.Dictionary<Integer, DecimalFormat> formatDictionary = new java.util.Hashtable<Integer, DecimalFormat>(); |
| 51 | String formatPattern = "0.000"; //$NON-NLS-1$ |
| 52 | DecimalFormat defaultFormat = org.opensourcephysics.numerics.Util.newDecimalFormat(formatPattern); |
| 53 | Object prevValue; |
| 54 | |
| 55 | /** |
| 56 | * Constructor for 1D int array. |
| 57 | * |
| 58 | * @param array the array |
| 59 | */ |
| 60 | public ArrayTable(int[] array) { |
| 61 | tableModel = new ArrayTableModel(array); |
| 62 | init(); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Constructor for 2D int array. |
| 67 | * |
| 68 | * @param array the array |
| 69 | */ |
| 70 | public ArrayTable(int[][] array) { |
| 71 | tableModel = new ArrayTableModel(array); |
| 72 | init(); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Constructor for 1D double array. |
| 77 | * |
| 78 | * @param array the array |
| 79 | */ |
| 80 | public ArrayTable(double[] array) { |
| 81 | tableModel = new ArrayTableModel(array); |
| 82 | init(); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Constructor for 2D double array. |
| 87 | * |
| 88 | * @param array the array |
| 89 | */ |
| 90 | public ArrayTable(double[][] array) { |
| 91 | tableModel = new ArrayTableModel(array); |
| 92 | init(); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Constructor for 1D String array. |
| 97 | * |
| 98 | * @param array the array |
| 99 | */ |
| 100 | public ArrayTable(String[] array) { |
nothing calls this directly
no test coverage detected