• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Add Remove item in a jList with a jButton

 
protected system
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,
i'm new here and beginner in java.
my job is to modify a java code where i have two button :
-Add
-Remove

Items are added in a jList
so my problem is: i can add item but i can't remove item
i try this:


but it only clears the jList but not remove item.

So my code for jButtonAdd is:


How can i modify this code to remove items after they were added with the jButtonAdd

Thank you
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there's a whole bunch of DefaultListModel methods that start with remove...

did you try any of those?
 
protected system
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i tried like this:



i still have the same problem, it only clears the jlist but not remove items.
thank you
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> it only clears the jlist but not remove items.

to me, this reads - it removes all the items (clears), but doesn't remove the items

you'd be better off to post a sample program that we can copy/paste/compile/run/observe
along with instructions to reproduce the problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic