• Post Reply Bookmark Topic Watch Topic
  • New Topic

transfer item in jlist  RSS feed

 
Edrey Ching
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to transfer item from left list to right list at the same time the selected item will remove from the left list, its like cut and paste ... thanks in advance
Untitled.png
[Thumbnail for Untitled.png]
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the section from the Swing tutorial on How to Use Lists.

The "Hire / Fire" example will show you the basics of what you need to do.

The "Fire" button shows you how to remove an item from the ListModel

The "Hire" button shows you how to add an item to the ListModel

Combine the two concepts into your single "Transfer" button and you have your solution.

The main difference is that the "Hire" button gets the name from the text field. In your case you will need to get the selected item from the JList BEFORE you remove it from the model.
 
Edrey Ching
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!