JList add/remove Item?

The problem is listModel. AddElement(listaRosa. GetSelectedValue()); listModel.

RemoveElement(listaRosa. GetSelectedValue()) you may be adding an element and immediatly removing it since both add and remove operations are on the same listModel Try private void aggiungiTitolareButtonActionPerformed(java.awt.event. ActionEvent evt) { DefaultListModel lm2 = (DefaultListModel) listaTitolari.getModel(); DefaultListModel lm1 = (DefaultListModel) listaRosa.getModel(); if(lm2 == null) { lm2 = new DefaultListModel(); listaTitolari.

SetModel(lm2); } lm2. AddElement(listaTitolari. GetSelectedValue()); lm1.

RemoveElement(listaTitolari. GetSelectedValue()); }.

The problem is listModel. AddElement(listaRosa. GetSelectedValue()); listModel.

RemoveElement(listaRosa. GetSelectedValue()); you may be adding an element and immediatly removing it since both add and remove operations are on the same listModel. Try private void aggiungiTitolareButtonActionPerformed(java.awt.event.

ActionEvent evt) { DefaultListModel lm2 = (DefaultListModel) listaTitolari.getModel(); DefaultListModel lm1 = (DefaultListModel) listaRosa.getModel(); if(lm2 == null) { lm2 = new DefaultListModel(); listaTitolari. SetModel(lm2); } lm2. AddElement(listaTitolari.

GetSelectedValue()); lm1. RemoveElement(listaTitolari. GetSelectedValue()); }.

It removes from the first, but overwrites the second list.... – Franky Mar 6 at 20:09 @Franky ok. I have edited it slightly. Try this.

– Bala R Mar 6 at 20:11 still owerwriting the inserted element :( – Franky Mar 6 at 20:23 @Franky how about now? – Bala R Mar 6 at 20:35 now nothing happens... neither add or remove! – Franky Mar 6 at 20:37.

I searched how to add items in JList and try it. It adds in JList but there is something wrong. Please see the picture.

All that I try has same results. Pic2 - is alsmost the same with pic1, only a scrollbar is added. Which means that the items are added, it just did not show.

Pic3 - I click the scrollbar and the two items that I added show. I think I am missing something. I also use revalidate() and repaint() to refresh JList.

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