1 23 24 29 30 package com.sun.enterprise.tools.common.properties; 31 32 37 public class PropertyElementsTableModel extends javax.swing.table.AbstractTableModel { 38 39 PropertyElements v = null; 40 41 private static java.util.ResourceBundle bundle = 42 java.util.ResourceBundle.getBundle("com.sun.enterprise.tools.common.properties.Bundle"); 44 45 public PropertyElementsTableModel(PropertyElements v) { 46 this.v = v; 47 } 48 49 public java.lang.Object getValueAt(int param, int param1) { 50 Object retVal = ""; if (param < v.getLength()) 52 retVal = v.getAttributeDetail(param, param1); return retVal; 54 } 56 57 public int getRowCount() { 58 return v.getLength() + 1; 59 } 60 61 public int getColumnCount() { 62 return v.getWidth(); 63 } 64 65 66 public boolean isCellEditable(int row, int col) { 67 return true; 68 } 69 70 public void setValueAt(Object val, int row, int col) { 71 int pre = v.getLength(); 72 v.setAttributeDetail(val, row, col); if (v.getLength() < pre) { 74 fireTableStructureChanged(); 76 } 77 } 78 79 public String getColumnName(int col) { 80 if (0 == col) 81 return bundle.getString("COL_HEADER_NAME"); 82 if (1 == col) 83 return bundle.getString("COL_HEADER_VALUE"); 84 throw new RuntimeException (bundle.getString("COL_HEADER_ERR_ERR_ERR")); 85 } 86 87 public static void main(String args[]) { 88 PropertyElements pe = new PropertyElements(args); 89 javax.swing.JTable tab = new javax.swing.JTable (new PropertyElementsTableModel(pe)); 91 javax.swing.JScrollPane sp = new javax.swing.JScrollPane (tab); 92 javax.swing.JFrame f = new javax.swing.JFrame (); 93 f.addWindowListener(new CloseTestWindow(pe)); 94 f.getContentPane().add(sp); 95 f.show(); 96 } 97 98 static class CloseTestWindow extends java.awt.event.WindowAdapter { 99 private PropertyElements myPE; 100 public CloseTestWindow(PropertyElements pe) { 101 myPE = pe; 102 } 103 public void windowClosing(java.awt.event.WindowEvent e) { 104 System.out.println(myPE.dumpIt()); System.exit(0); 106 } 107 } 108 109 110 } 111 | Popular Tags |