Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException

 
ulvi ugur
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> My JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException;

mine doesn't
 
ulvi ugur
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ulvi ugur wrote: . . . false alarm . . .
It wasn't a false alarm, as you will see if you look at the links I provided you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic