Jump to content
  • Advertisement
Sign in to follow this  
cbratton

[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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Roboguy
Try:

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!