This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException" Watch "JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException" New topic
Author

JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException

ulvi ugur
Ranch Hand

Joined: Aug 05, 2003
Posts: 46

Hi Guys,

My JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException; should one handle this in a try/catch or is there a better way to do this that no exceptions are thrown ?

Cheers,

Ulvi
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> My JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException;

mine doesn't
ulvi ugur
Ranch Hand

Joined: Aug 05, 2003
Posts: 46

Good one Michael

Figured it out myself, two events happenning at the same time and two different threads try to remove the tabs in a race condiition.

Sorry for the false alarm and thanks for the attention.

CHeers,

Ulvi
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38044
    
  22
ulvi ugur wrote: . . . two events happenning at the same time and two different threads . . .
If you read the documentation, it says
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
You should read that link, and never try to access a Swing component from any thread but the EDT.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38044
    
  22
ulvi ugur wrote: . . . false alarm . . .
It wasn't a false alarm, as you will see if you look at the links I provided you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException
 
Similar Threads
Socket connection error in Tomcat
File.exists() Problem
Index out of bound exception while comparing elements in the same list dynamically
websphere 5.0 jdbc problem
Exception