• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Moving data from JList to JTable

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic