File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 38788
    
  23
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: 38788
    
  23
ulvi ugur wrote: . . . false alarm . . .
It wasn't a false alarm, as you will see if you look at the links I provided you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException