How to transfer the elements from one JList to other JList in Java?

The model doesn't know about selection The JList provides several methods to get the selected item or selected index. Use those methods to get the items and add them to the other list's model.

The model doesn't know about selection. The JList provides several methods to get the selected item or selected index. Use those methods to get the items and add them to the other list's model.

At present, the list models of both the JList is DefaultListModel but I can change that if required. The DefaultListModel doesn't provide any method like getSelectedItem or getSelectedItems ... – Yatendra Goel Jan 22 '10 at 15:21 Right, you have to implement your own model in that case. Or derive from DefaultListModel and extend it appropriately.

– Joey Jan 22 '10 at 15:36.

You have two JLists, then you also have their respective ListModels. Depending on how you implemented them you can just remove the elements from one model and add them to the other. Note, though, that the ListModel interface doesn't care for more than element access by default, so you probably have to implement add and remove methods there by yourself.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions