• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Help JTree is not displaying inside of JFrame

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
reply
    Bookmark Topic Watch Topic
  • New Topic