File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes setting focus to a tab in a JTabbedPane Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "setting focus to a tab in a JTabbedPane" Watch "setting focus to a tab in a JTabbedPane" New topic
Author

setting focus to a tab in a JTabbedPane

Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
Hi guys,

I have a frame that has a JTabbedPane(with 2 tabs) & a JButton. As is obvious, at a time contents of only one tab can be seen, and that of the other are hidden...

My problem is at the click of the button, focus ahould be set to the tab whose contents are not seen and thus its contents should become visible.

I am looking only for code that can set the focus to the hidden tab when the JButton is clicked. i.e. the code that can be placed inside the actionPerformed(ActionEvent) method.

Any help provided regarding this would be greately appreciated...


If your new Big Idea doesn't scare the hell out of you, <br />it's probably not a "new Big Idea".
prashant gour
Ranch Hand

Joined: Feb 07, 2006
Posts: 45
on action performed of button

// index tabbed index
TabbedPane.setSelectedIndex(int index);
Parth Bhatt
Ranch Hand

Joined: Oct 19, 2005
Posts: 58
Thanks prashant... That solves my problem...
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: setting focus to a tab in a JTabbedPane
 
Similar Threads
on Control+tab how to show next tab in tabbedpane
Setting hot keys
JTabbedPane with Keyevents
change the focus to the new tab
swing(JComboBox)urgent