JTree reflects JTabbedPane

Hi,

I have a JTree which has a TreeSelectionListener listening to it, when i click on a node of the JTree it opens a tab in the Tabbed pane...

publicvoid valueChanged(TreeSelectionEvent e){

JTree sourceTree = (JTree) e.getSource();

DefaultMutableTreeNode node = (DefaultMutableTreeNode) sourceTree.getLastSelectedPathComponent();

if (node ==null)return;

Object nodeInfo = node.getUserObject();

String[] criteria =null;

if (node.isLeaf()){

String transName = (String) nodeInfo;

if(!tabList.contains(transName)){

tabList.add(transName);

criteria = selectCriteria(transName);

tabbedPane.addTab(transName, null, criteria);

}

util.updateStatusBar(transName);

}

}

Now what i would like to do is, when the user has opened the tabs, and then clicks on a node the pertaining tab in the Tabbedpane should comealive.

Is there a way to get a tab in the tabbed pane into focus?

I have the tabbedPane object with me so i figure there should be a way to get this done...

Any pointers would be welcome.

Thank You!!

-Uday

[1576 byte] By [uday_prakasha] at [2007-11-27 2:20:29]
# 1

Hi,

got to the solution myself....

it was not that complicated here goes..

public void valueChanged(TreeSelectionEvent e) {

JTree sourceTree = (JTree) e.getSource();

DefaultMutableTreeNode node = (DefaultMutableTreeNode) sourceTree.getLastSelectedPathComponent();

if (node == null) return;

Object nodeInfo = node.getUserObject();

String[] criteria = null;

int tabCount = 0;

if (node.isLeaf()) {

String transName = (String) nodeInfo;

if(!tabList.contains(transName)){

tabList.add(transName);

criteria = selectCriteria(transName);

tabbedPane.addTab(transName, null, criteria);

}

util.updateStatusBar(transName);

tabbedPane.setSelectedIndex(tabList.indexOf(transName));

}

}

uday_prakasha at 2007-7-12 2:21:51 > top of Java-index,Desktop,Core GUI APIs...