• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTabbedPane problem  RSS feed

 
Eli Daum
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I initially set up a JTabbedPane the default selected index is 0. However at runtime when a user clicks on the 0 index it will not bring up the panel associated with index 0. I tried setSelectedIndex() to -1 , and I get a runtime "array out of bounds exception" however it does not kill the process anybody out there with any ideas
Thanks Eli Daum
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you are adding a panel to your JTabbedPane 0 in a Tabbed Selection Listener? Is this correct? If so, you will probably need to add that panel at runtime. Why would you want to show a JTabbedPane that is initually empty on the first tab? If this is nowhere close to your problem, let us know, and/or post some of you code where the problem is.
As far as your array index out of bounds, that's because your tabs are indexed 0 through .... Just like a normal Array[]. There is not an index of -1.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"elid" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!