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 JTabbedPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTabbedPane " Watch "JTabbedPane " New topic
Author

JTabbedPane

Laurent S
Greenhorn

Joined: Sep 27, 2001
Posts: 15
Hello,
I've a frame with a tree on the left and a TabbedPane a on the right. I've 3 tab in my TabbedPane. I would like to change the visible tab when i clic on a node in the tree. My code is

public void valueChanged(TreeSelectionEvent event)
{
TreePath path = tree.getSelectionPath();
if (path == null) return;
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
NodeInfo nInfo = (NodeInfo)selectedNode.getUserObject();
if (nInfo.getType().equals("company"))
{
tabbedPane.getComponentAt(1).setVisible(true);
}
}

but it doesn't work :/
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Laurent,
Try to use the setSelectedIndex() method for JTabbedPane instead you will probably have more luck.
if (nInfo.getType().equals("company"))
{
tabbedPane.setSelectedIndex( 1 );
}
Regards,
Manfred.
Laurent S
Greenhorn

Joined: Sep 27, 2001
Posts: 15
Thx a lot
 
 
subject: JTabbedPane
 
Similar Threads
Whether tag handlers are needed in creating a t:tree component
Can I add a checkbox in front of a tree node?
Need a Frame Refresh, when invoking a tree event
problem insert with DB2
Java 2D, displaying an image