dcsimg
Updating JTree from other JPanel
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, July 22, 2002 08:08 AM

The main class of my app is made up of a JSplitPane the JSplitPane on the left contains a JTree and JButtons to perform tasks on the files listed in the JTree, nested in JPanels. The JSplitPane on the right is made up of JTabbedPanes, and nested JTabbedPanes, all in their own classes extending JPanels. In one of the JTabbedPanes I have a JPanel that allows you to create a new file and save it in a folder which is one of the folders in my JTree. My question is how to I access the JTree from my JPanel? Do I have to make the JPanel containing the JTree a static class with an identifier so that I can call whatever.((DefaultTreeModel)yourTree.getModel()).reload(); or is there something else I have to do?    More>>

The main class of my app is made up of a JSplitPane the JSplitPane on the left contains a JTree and JButtons to perform tasks on the files listed in the JTree, nested in JPanels. The JSplitPane on the right is made up of JTabbedPanes, and nested JTabbedPanes, all in their own classes extending JPanels. In one of the JTabbedPanes I have a JPanel that allows you to create a new file and save it in a folder which is one of the folders in my JTree.

My question is how to I access the JTree from my JPanel? Do I have to make the JPanel containing the JTree a static class with an identifier so that I can call

			
whatever.((DefaultTreeModel)yourTree.getModel()).reload();

or is there something else I have to do?    <<Less

Re: Updating JTree from other JPanel

Posted By:   Gautam_Marwaha  
Posted On:   Monday, July 22, 2002 10:47 PM

One simple way to achieve this is to pass the left side JPanel (containing the JTree) object to any other JPanel on the right (in the constructor) which needs to access the JTree. Implement a getter getTree() on the left JPanel to allow JTree access -



//In right panel - leftPanel is the left JPanel instance
JTree jtree = leftPanel.getTree();
//do whatever with the JTree
About | Sitemap | Contact