• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTabbedPane

 
Laurent S
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx a lot
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic