1 package org.oddjob.monitor.view; 2 3 import java.util.ArrayList ; 4 import java.util.List ; 5 import java.util.Map ; 6 7 import javax.swing.event.TableModelEvent ; 8 import javax.swing.table.AbstractTableModel ; 9 10 15 16 public class PropertyTableModel extends AbstractTableModel { 17 private static final long serialVersionUID = 20051109; 18 19 20 private List keys = new ArrayList (); 21 22 23 private List values = new ArrayList (); 24 25 private final String colNames[] = { "Name", "Value" }; 26 27 public void update(Map props) { 28 keys = new ArrayList (props.keySet()); 29 values = new ArrayList (props.values()); 30 fireTableChanged(new TableModelEvent (this)); 31 } 32 33 36 public int getRowCount() { 37 return keys.size(); 38 } 39 40 43 public int getColumnCount() { 44 return 2; 45 } 46 47 50 public String getColumnName(int columnIndex) { 51 return colNames[columnIndex]; 52 } 53 54 57 public Object getValueAt(int rowIndex, int columnIndex) { 58 if (columnIndex == 0) { 59 return keys.get(rowIndex); 60 } 61 else { 62 return values.get(rowIndex); 63 } 64 } 65 } 66 | Popular Tags |