• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> My JTabbedPane.removeAll() throws java.lang.IndexOutOfBoundsException;

mine doesn't
 
ulvi ugur
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 80099
413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 80099
413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic