aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Unable to delete a list entry at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Unable to delete a list entry at runtime" Watch "Unable to delete a list entry at runtime" New topic
Author

Unable to delete a list entry at runtime

Mansoor Khan
Greenhorn

Joined: Apr 14, 2008
Posts: 17
I have a list which consists of names and a button to delete the selected name when clicked. The names in the list are read from a database. When I click on the button to delete the selected entry, I get an error like this on the terminal window and the entry is not deleted:

Error : java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 3


The code for the same is as below :


The bug may be evident but I am not able to fix it. Kindly help me get over with this.

kingmansoor
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2176
    
    7
Read the JList API and follow the link to the Swing tutorial on "How to Use Lists' for a working example that dynamically adds/removes items from a JList.
Mansoor Khan
Greenhorn

Joined: Apr 14, 2008
Posts: 17
I did that. Can you please help me find where I am wrong in my code?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4530
    
    5

Mansoor Khan wrote:I did that. Can you please help me find where I am wrong in my code?

Not without an SSCCE.


luck, db
There are no new questions, but there may be new answers.
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
I'd recommend using the ListModel for adding / removing of items (like in the swing tutorials). Here's a working mini-example:



Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to delete a list entry at runtime