1 Replies - 516 Views - Last Post: 09 August 2012 - 02:35 AM Rate Topic: -----

#1 vbabey  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 30-July 12

Remove item from JList

Posted 09 August 2012 - 02:19 AM

I wanted to remove items in a JList which was designed so as to update automatically in accordance with the inputs in runtime....

 int selectedIndex = userList.getSelectedIndex();
        userList.remove(selectedIndex);
        String removeUser = userList.getSelectedValue().toString();
       JOptionPane.showMessageDialog(null,"Removed item:"+removeUser);




this is a part from the code...
this is not working
can anyone help me?

Is This A Good Question/Topic? 0
  • +

Replies To: Remove item from JList

#2 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 797
  • View blog
  • Posts: 2,423
  • Joined: 29-July 11

Re: Remove item from JList

Posted 09 August 2012 - 02:35 AM

It sounds as if when you remove an item from the array or listmodel backing the JList, you're not refreshing the JList. Try calling setListData() or setModel() after removing the item. Good luck!
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1