# [java] A question on JTabbedPane...

This topic is 5391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This may sound ridiculously simple to some of you...and I hope not for the sake of my own embarassment. Anyways, here goes... I have created a JTabbedPane with a unique name and unique JPanel. How do I loop through all the Tabs in my JTabbedPane by name and find the one I am looking for? For example: ------------------- John \ Bob \ Martha How do I grab the JPanel that John represents? Really all I have on this JPanel is a JTextPane and a JTextField, and I want a new incoming status message to be appended to their JTextPane...but in doing so I have to know which Pane they are on first! I have been running around all day with this and have gotten no where. This isn't for some class project or anything...I'm writing my own IM client...and would like tabbed messaging to be implemented. I would be grateful to anyone who could point me to an example. :) Thanks, dev

##### Share on other sites
Try:
tabbedFrame.getComponent(tabbedFrame.indexOfTab("John"));

btw, I recommend checking the Java API docs before asking here(not intended as an insult, just a suggestion, heh).

[Edited by - Roboguy on October 11, 2004 11:12:28 PM]

##### Share on other sites
I did check the API, since you ask; furthermore, that didn't work.

I have noticed that if I do not call a UIManager to set the look and feel to the system L&F that I do not encounter this problem. I do not see how the two are possibly related, but that appears to be the problem.

I did have exactly what you wrote and believed it to be wrong, but discovering that disabling L&F is the only way I'm going to get it to work makes me wonder if I should just scrap the use of a JTabbedPane...because that Motif look drives me insane. ;)

Thank you for your help...if you know of any other methods to accomplish the same thing please let me know.

dev

##### Share on other sites
Post the relevent code, b/c that seems like it should not be happening. You shouldn't have to trade one for the other like that.

##### Share on other sites
I'd rather not post all of my code...I'm at 5500 lines right now and it'd be rather tedious on all of you to review it even though the part I am concerned about is only a couple of lines long.

I have noticed that if I change my XP theme, the problem no longer occurs. Why in the -hell- is a visual theme messing up the way my tabs are displayed? Makes no sense to me.

I'll consider this thread closed, since I believe my visual style is the cause of this strange tabbedpane layout. Weird.

If my post on the Sun forums goes anywhere I'll let you know here...

Thanks,

dev

##### Share on other sites
hmm, sounds kind of like a bug in Java...

##### Share on other sites
Quote:
 Original post by RoboguyTry:tabbedFrame.getComponent(tabbedFrame.indexOfTab("John"));
I think that you should use getComponentAt instead of getComponent. They return different things and this might work. This is however not needed functionality as you should keep instances of the panels that you have added to the JTabbedPane elsewhere and just let Swing take care of the JTabbedPane.

• 21
• 13
• 9
• 17
• 13