• 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.getSelectedIndex

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an applet with several of my own beans on it. One of them is a panel with a JTabbedPane on it, with four tabs. I want to know, from another bean, which of those tabs is currently selected.
My actual line of code is :
int index = topLevelApplet.theResultsPanel.ResultsTabs.getSelectedIndex();
but index always has the value 0, no matter which tab is selected.
I'm fairly sure I'm reffering to the correct thing, because I get no compilation errors, and also because
int index = topLevelApplet.theResultsPanel.ResultsTabs.getTabCount();
returns the value 4 - for the 4 Tabs as I expect.
Any clues as to where I should look for the error ?
Thanks,
Kate
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kate
Have you had a look at:
. It has some info on setSelectedIndex(0). Could it be that you have set all of them to 0. I am relatively new to this, but remember doing something similar myself.
Hope it helps
Mark
 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
did you miss something out of your reply? I can't see the reference you are pointing me to. Could you send it again please
Thankyou,
Kate
 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I just checked how I added the tabs in the first place, and I did ...
ResultsTabs.insertTab("Market", null, getMarketTab(), null, 0);
ResultsTabs.insertTab("History", null, getHistoryTab(), null, 1);
etc. where I think the number at the end is the tabIndex ? so, I have set it to 0, 1, 2, 3, etc .
(not altogether that I have checked your suggestion correctly !!!) I think VisualAge set these for me.
any more thoughts,
Thanks,
Kate
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "left out reference" from Mark (try to edit his post and you can see it).
http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html
 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, Thanks, I've read that and had an idea. I just used the removeTabAt() method to remove the tab at 0. successive calls to this worked ... in the sense that the next tab became the tab at 0 each time, but all the tabs still appeared on the applet. Aha ! I am not refreshing something that I should be.
That's as far as my inspiration went though !
Kate
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic