Populating Object[][]

M

MikeSmith813

I have a HashMap and I need to fill a 2-dimential array, Object[][],
with the key-value pairs. I need to do this to supply a JTable with
the data from the HashMap.

I do not know what data is in the HashMap or what the key names are.

Can someone please show me how to do this?

Thanks!
 
D

Daniel Dyer

I have a HashMap and I need to fill a 2-dimential array, Object[][],
with the key-value pairs. I need to do this to supply a JTable with
the data from the HashMap.

I do not know what data is in the HashMap or what the key names are.

Can someone please show me how to do this?

Did you read
http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html ?

- Oliver

Or for an alternative approach to the underlying problem don't use the
DefaultTableModel, write your own instead:

http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/table/TableModel.html
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/table/AbstractTableModel.html


Dan.
 
H

hilizbabe

You need to write some code to get the data from hashmap using
entrySet() and update the tablemodel. With QuickTable, a free JTable
based javabean, you can do this in one line

quickTable.refreshDataObject(yourHashMap.entrySet(), null);

http://quicktable.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top