This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to Add Remove item in a jList with a jButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to Add Remove item in a jList with a jButton" Watch "How to Add Remove item in a jList with a jButton" New topic
Author

How to Add Remove item in a jList with a jButton

protected system
Greenhorn

Joined: Nov 30, 2012
Posts: 3
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

Joined: Jun 09, 2003
Posts: 4632
there's a whole bunch of DefaultListModel methods that start with remove...

did you try any of those?
protected system
Greenhorn

Joined: Nov 30, 2012
Posts: 3
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

Joined: Jun 09, 2003
Posts: 4632
> 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Add Remove item in a jList with a jButton
 
Similar Threads
Drag and Drop between 2 JLists - ReportingListTransferHandler
JList Problem
HashMap problem
horizontal JList
JList SelectionForeground problem when BOLD