1 Reply Latest reply on Jun 26, 2013 6:37 AM by 952174

    SwiXML - JTree LazyLoad Expand listener issue

    952174

      Hi,

       

      Iam creating UI using SwiXML which is based on Swing. Able to create a Tree structure using the below code logic. Issue is, unable to invoke expansion listener method.

      It would be great, if you can suggest on this issue.

       

      We have configured Java file in a xml file as below

      <scrollpane id="neh_task_tree">
          <gridbagconstraints insets="5,5,5,5" gridx="1" gridy="1" weightx="1.0"
                              weighty="1.0" fill="GridBagConstraints.BOTH"
                              anchor="GridBagConstraints.WEST"/>
          <tree id="neh_prod_activity_task_tree" initclass="com.oracle.appsfdoc.fusion.sos.LazyLoadDemo" Font="ARIAL-BOLD-14" VisibleRowCount="5"/>
      </scrollpane>

       

       

       

      public class LazyLoadDemo extends DefaultTreeModel {

              JTree tree;

              final TreeNode root;

              public LazyLoadDemo() {

                  super(new DefaultMutableTreeNode("ROOT"));

                  System.out.println("LazyLoadDemo");

                  root = (DefaultMutableTreeNode) super.getRoot();

                  createNodes(root);

                  tree = new JTree((TreeNode)root);

                  //tree.addTreeExpansionListener(this);

                  //tree.addTreeWillExpandListener(this);

                  System.out.println("BEFORE HANDLER");

                  tree.addTreeExpansionListener(new TreeExpansionListener(){

                         

                              @Override

                              public void treeCollapsed(TreeExpansionEvent e)

                              {

                                  System.out.println("Node collapsed at " + e.getPath() + "\n");

                              }

                             

                              @Override

                              public void treeExpanded(TreeExpansionEvent e)

                              {

                                  System.out.println("Node expanded at " + e.getPath()+ "\n");

                              }

                         

                          });            System.out.println("AFTER HANDLER");

              }

          private void treeForumReviewTreeExpanded(javax.swing.event.TreeExpansionEvent evt) {//GEN-FIRST:event_treeForumReviewTreeExpanded

          // TODO add your handling code here:

          System.out.println("treeForumReviewTreeExpanded");

          /*DefaultMutableTreeNode node = (DefaultMutableTreeNode) evt.getPath().getLastPathComponent();

                  ForumView fv = (ForumView) node.getUserObject();

              refreshReview(fv);*/

          }       

              private TreeNode createNodes(TreeNode root) {

                          DefaultMutableTreeNode grandparent;

                          DefaultMutableTreeNode parent;

                          DefaultMutableTreeNode child;

                          DefaultMutableTreeNode temp = (DefaultMutableTreeNode)root;

                          root = new DefaultMutableTreeNode("San Francisco");

       

                          grandparent = new DefaultMutableTreeNode("Potrero Hill");

                          temp.add(grandparent);

                          //

                          parent = new DefaultMutableTreeNode("Restaurants");

                          grandparent.add(parent);

                          child = new DefaultMutableTreeNode("Thai Barbeque");

                          parent.add(child);

                          child = new DefaultMutableTreeNode("Goat Hill Pizza");

                          parent.add(child);

                          //

                          parent = new DefaultMutableTreeNode("Grocery Stores");

                          grandparent.add(parent);

                          child = new DefaultMutableTreeNode("Good Life Grocery");

                          parent.add(child);

                          child = new DefaultMutableTreeNode("Safeway");

                          parent.add(child);

                         

                          grandparent = new DefaultMutableTreeNode("Noe Valley");

                          temp.add(grandparent);

                          //

                          parent = new DefaultMutableTreeNode("Restaurants");

                          grandparent.add(parent);

                          child = new DefaultMutableTreeNode("Hamano Sushi");

                          parent.add(child);

                          child = new DefaultMutableTreeNode("Hahn's Hibachi");

                          parent.add(child);

                          //

                          parent = new DefaultMutableTreeNode("Grocery Stores");

                          grandparent.add(parent);

                          child = new DefaultMutableTreeNode("Real Foods");

                          parent.add(child);

                          child = new DefaultMutableTreeNode("Bell Market");

                          parent.add(child);

                         

                          return root;

                      }

      }

       

      Thanks in advance,

      Samba.