Re: How to know when does a JTree become visible/invisible?
- From: bcr666 <bcr666@xxxxxxxxx>
- Date: 11 May 2007 19:47:39 -0700
You say you have tabs. I assume you are using a JTabbedPane. I would
make the content in each of the tabs its own class that implements an
interface.
public interface TreeWidget {
public void loadTree(Object parameter);
}
public class TabPanelA implements TreeWidget {
JTree tvwTreeA = new JTree(new DefaultTreeModel(new
DefaultMutableTreeNode("Root")));
... // other stuff here
public void loadTree(Object parameter) {
... // stuff here to load tree
}
}
public class MyFrame extends JFrame {
JButton cmdLoad = new JButton("Load");
JTabbedPane tabbedPane = new JTabbedPane();
public MyFrame() {
this.setSize(800, 600);
this.setVisible(true);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(cmdLoad, BorderLayout.NORTH);
this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
tabbedPane.addTab("Panel A", new TabPanelA());
cmdLoad.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Object parameter = ...// parameter to pass to the tree
((TreeWidget)tabbedPane.getSelectedComponent()).loadTree(parameter);
}
});
}
.
- Follow-Ups:
- Re: How to know when does a JTree become visible/invisible?
- From: lichuan.nj@xxxxxxxxx
- Re: How to know when does a JTree become visible/invisible?
- References:
- How to know when does a JTree become visible/invisible?
- From: lichuan.nj@xxxxxxxxx
- How to know when does a JTree become visible/invisible?
- Prev by Date: Re: Suggestions for higher-level Swing frameworks?
- Next by Date: Re: How to know when does a JTree become visible/invisible?
- Previous by thread: Re: How to know when does a JTree become visible/invisible?
- Next by thread: Re: How to know when does a JTree become visible/invisible?
- Index(es):