T
tolu45
I have a problem with my code. I am trying to select some elements in a
Jlist to populate another JList. The code does not work as i desire. It
refreshs what is in the second Jlist with the new item selected intead
of increasing the number of items by +1.Could you have a look at the
code and suggest what could be the problem and how i can solve it?
The code is as follows:
jList3.addListSelectionListener(new
javax.swing.event.ListSelectionListener()
{
public void valueChanged(javax.swing.event.ListSelectionEvent e)
{
DefaultListModel listModel = new DefaultListModel();
String listElem = "";
if (e.getValueIsAdjusting() == true) {
if (jList3.getSelectedIndex() > -1) {
//No selection, disable fire button.
listModel.addElement(jList3.getSelectedValue().toString());
jList4.setModel(listModel);
}
}
Jlist to populate another JList. The code does not work as i desire. It
refreshs what is in the second Jlist with the new item selected intead
of increasing the number of items by +1.Could you have a look at the
code and suggest what could be the problem and how i can solve it?
The code is as follows:
jList3.addListSelectionListener(new
javax.swing.event.ListSelectionListener()
{
public void valueChanged(javax.swing.event.ListSelectionEvent e)
{
DefaultListModel listModel = new DefaultListModel();
String listElem = "";
if (e.getValueIsAdjusting() == true) {
if (jList3.getSelectedIndex() > -1) {
//No selection, disable fire button.
listModel.addElement(jList3.getSelectedValue().toString());
jList4.setModel(listModel);
}
}