public static AbstractTableModel getProperties ( final CSProperties p ) { return new AbstractTableModel ( ) { @ Override public int getRowCount ( ) { return p . keySet ( ) . size ( ) ; } @ Override public int getColumnCount ( ) { return 2 ; } @ Override public Object getValueAt ( int rowIndex , int columnIndex ) { if ( columnIndex == 0 ) { return " " + p . keySet ( ) . toArray ( ) [ rowIndex ] ; } else { return p . values ( ) . toArray ( ) [ rowIndex ] ; } } @ Override public boolean isCellEditable ( int rowIndex , int columnIndex ) { return columnIndex == 1 ; } @ Override public void setValueAt ( Object aValue , int rowIndex , int columnIndex ) { if ( columnIndex == 1 ) { String [ ] keys = p . keySet ( ) . toArray ( new String [ 0 ] ) ; p . put ( keys [ rowIndex ] , aValue . toString ( ) ) ; } } @ Override public String getColumnName ( int column ) { return column == 0 ? "Name" : "Value" ; } @ Override public Class < ? > getColumnClass ( int columnIndex ) { return String . class ; } } ; }
Get the KVP as table .