I have a HashTable like
HashTable<String, String> table=new HashTable<String, String>();
table.put("1","ABC");
.......continues
Now with enumeration I can get this key and values in two strings say str1 and str2.
I want to add this two string values in a JTable. Every time a new value will iterate and will add in the JTable. How to do this?
Remember I have no option to use a HashMap.
You can use this:
DefaultTableModel dtm = new DefaultTableModel();
JTable table = new JTable(dtm);
for(Entry<?, ?> entry: yourHashTable.entrySet()) {
dtm.addRow(new Object[] {entry.getKey(), entry.getValue()});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.