aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Help JTree is not displaying inside of JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help JTree is not displaying inside of JFrame " Watch "Help JTree is not displaying inside of JFrame " New topic
Author

Help JTree is not displaying inside of JFrame

kisner knowll
Greenhorn

Joined: Dec 15, 2002
Posts: 1
Hello,
I have a frame application, inside the frame I have a jtable. when the users double click on a row from the table. I want to display an internalJFrame, which contain a tree with data on it. I try different combination with no luck. Below is the code where I am calling the internalJFrame and the internalJFrame code. Thank you for your help.
if (e.getClickCount () == 2) {
try {
String tempID = jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString();
selectedID = Long.parseLong(tempID);
}catch (NumberFormatException nfe) {
}
hierarchicalPanel = new HierarchicalPanel(selectedID);
hierarchicalPanel.setAddedToDesktop (true);
desktop.add(hierarchicalPanel);
hierarchicalPanel.setVisible(true);
}
private HierarchalView hierarchalView;
//tree stuff
private DefaultMutableTreeNode root = null;
private DefaultTreeModel treeModel;
private CommRecord commRec;
private InstalledComponent installedAComponent;
private InstalledComponent installedZComponent;
private static boolean addedToDesktop;
/** Creates new form Hierarchical */
public HierarchicalPanel(long sipID) {
initComponents();
hierarchalView = new HierarchalView();
createNodes(sipID);
createTree();
}
/**
* create a JTree
*/
public void createTree() {
jTree1 = new JTree(treeModel);
jTree1.putClientProperty("JTree.lineStyle", "Angled");
jTree1.getSelectionModel()
.setSelectionMode(TreeSelectionModel
.DISCONTIGUOUS_TREE_SELECTION);
jTree1.setOpaque(false);
// tree.setCellRenderer(new AlphaRenderer());
jTree1.expandRow(0);
//this.llistenToTree(treeModel);
//popup();
//return tree;
}
/**
* Add nodes to model
*/
public void createNodes(long sipID){
DefaultMutableTreeNode root = null;
DefaultMutableTreeNode node = null;
DefaultMutableTreeNode child = null;
commRec = hierarchalView.getComRec(sipID);
long aComponentID = commRec.getSiteAInstalledComponent().getId();
long zComponentID = commRec.getSiteZInstalledComponent().getId();
long comID = commRec.getId();
//String desc = getSipData(sipID).getCustomerName();
root = new DefaultMutableTreeNode("SIP ID" + sipID);
treeModel = new DefaultTreeModel(root);
node = new DefaultMutableTreeNode("Communication ID");
root.add(node);
child = new DefaultMutableTreeNode("A InstallComponent " + aComponentID );
node.add(child);
child = new DefaultMutableTreeNode("Z InstallComponent " + zComponentID );
node.add(child);
System.out.println("finish inside node********");
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jTree1 = new javax.swing.JTree();
jPanel1.setLayout(new java.awt.BorderLayout());
jPanel1.setMinimumSize(new java.awt.Dimension(5, 100));
jPanel1.setPreferredSize(new java.awt.Dimension(5, 100));
jTree1.setMaximumSize(new java.awt.Dimension(78, 50));
jTree1.setMinimumSize(new java.awt.Dimension(80, 20));
jTree1.setPreferredSize(new java.awt.Dimension(100, 50));
jPanel1.add(jTree1, java.awt.BorderLayout.CENTER);
getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
pack();
}
/**
* Called whenever the value of the selection changes.
* @param e the event that characterizes the change.
*
*/
public void valueChanged(TreeSelectionEvent e) {
}
/** Getter for property addedToDesktop.
* @return Value of property addedToDesktop.
*
*/
public boolean isAddedToDesktop () {
return addedToDesktop;
}
/** Setter for property addedToDesktop.
* @param addedToDesktop New value of property addedToDesktop.
*
*/
public void setAddedToDesktop (boolean addedToDesktop) {
this.addedToDesktop = addedToDesktop;
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help JTree is not displaying inside of JFrame