wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Moving data from JList to JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Moving data from JList to JTable" Watch "Moving data from JList to JTable" New topic
Author

Moving data from JList to JTable

Mythily Jaganathan
Greenhorn

Joined: Aug 22, 2006
Posts: 19
Hi,
With the help Move and Remove button, I have to move datas between JList and JTable. Is it possible to do. Please help me.

Thanks in Advance
Mythily
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
If you set up your JList with a DefaultListModel you can add and remove items from the list. See the DefaultListModel api for methods to do this.
Same for the JTable, use a DefaultTableModel and you can add and remove rows and columns. You can change the values in cells with the TableModel interface.
With your button ActionListeners check for the selections in either component before you do the remove/add operations. Changes made to the models are sent to the view–components which update themselves.
You have choices to make along the way like where new rows/columns will be added into the JTable and where new items will be added to the JList.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Moving data from JList to JTable
 
Similar Threads
JTable Spread Sheet
jtable
JTable behaviour
JList in a JTable
Setting height of JTable headers?