• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 79268
377
  • 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: 79268
377
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic