This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTabbedPane.getSelectedIndex  RSS feed

 
kate damond
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • 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
 
Mark Gowdy
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!