This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help JTree is not displaying inside of JFrame  RSS feed

kisner knowll
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
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) {
hierarchalView = new HierarchalView();
* create a JTree
public void createTree() {
jTree1 = new JTree(treeModel);
jTree1.putClientProperty("JTree.lineStyle", "Angled");
// tree.setCellRenderer(new AlphaRenderer());
//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");
child = new DefaultMutableTreeNode("A InstallComponent " + aComponentID );
child = new DefaultMutableTreeNode("Z InstallComponent " + zComponentID );
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);
* 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;
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!