Javax.facex.tree.tree

Hi,
I am a newbie. I search for this class javax.faces.tree.tree. I search this topic and i found this link :
http://forum.java.sun.com/thread.jspa?forumID=427&threadID=597143
there is a link to a download side. But i do not find a download where the package with this class is in there.
Can somebody exlpain me, where i can get this jar files. If there is a download side with a lot of downloads please tell which one i have to download.
I hate jar files and classpath !!
Here is a example which i want to implement
I work with ibm rational web devoloper
import java.util.Iterator;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import javax.faces.event.PhaseId;
import javax.faces.tree.Tree;
* @author dewea116
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
public class MyActionListener implements ActionListener {
     public PhaseId getPhaseId() {
          System.out.println("getPhaseId called");
          return PhaseId.APPLY_REQUEST_VALUES;
     public void processAction(ActionEvent event) {
          System.out.println("processAction called");
          //     the component that triggered the action event
          UIComponent component = event.getComponent();
          System.out
                    .println("The id of the component that fired the action event: "
                              + component.getComponentId());
          //     the action command
          String actionCommand = event.getActionCommand();
          System.out.println("Action command: " + actionCommand);
          FacesContext facesContext = FacesContext.getCurrentInstance();
          Tree tree = facesContext.getTree();
          UIComponent root = tree.getRoot();
          System.out.println("----------- Component Tree -------------");
          navigateComponentTree(root, 0);
          System.out.println("----------------------------------------");
     private void navigateComponentTree(UIComponent component, int level) {
          //     indent
          for (int i = 0; i < level; i++)
               System.out.print(" ");
          //     print component id
          System.out.println(component.getComponentId());
          Iterator children = component.getChildren();
          //     navigate children
          while (children.hasNext()) {
               UIComponent child = (UIComponent) children.next();
               navigateComponentTree(child, level + 1);
Message was edited by:
acrobatmonkey
also the method component.getComponentId());
and event.getActionCommand();
does not work or is not there.
Message was edited by:
acrobatmonkey

i m not able to find above mentioned package

Similar Messages

  • Check Box in Tree (tree multiple selection)

    I need to create a 2 level hierarchy tree, where the user is allowed to make multiple selection on leaf node. One way is to use TableTree (TreeByNestingTableColumn), but with this I am unable to get the same look and feel of a simple Tree view.
    My questions are:
    1. Is there a way to enable multiple selection on a simple Tree?
    2. If the answer to question 1 is no, then is there a way to add check boxes to the Tree elements (be it parent or leaf)?
    3. Is there anything that can be done to solve this issue without using TableTree?
    Thanks in advance.

    Hi,
    Please go through Multiselection in Tree control thread.
    The solution outline is like this:
    1. When you click on a leaf, you mark it as selected and you can also store it in the context.
    2. Click as many leaves as you like and the onAction will mark each of them as selected.
    3. There's no need to do a CTRL+click, only normal clicks.
    4. Once done you can find out all the marked leaves.
    Regards,
    Satyajit.

  • Problem when expanding Tree - Tree with nested table column

    Hi, i have created the tree using the Tree with nested table column.
    I have created a node called TREE_ROOT in the context.
    This node has few attributes which includes children_loaded, is_leaf, is_expanded.
    I have created the recursive node TREE_SUB for the above node TREE_ROOT.
    In the view, i have created the table with the master column. The above attributes have been mapped accordingly. I have created the action handler for load_children.
    In this action handler method, i receive the context_element correctly. In this method, i determine the children of the selected element and the resulting children are attached to this context_element.
    But the problem is: when i add elements to context_elements in the method load_children, these
    elements get added to the node TREE_ROOT as well.
    Please help.
    thanks and best regards,
    Pramod

    I just use some types defined in this user... Well, I hope you know what is the type definition of d_period_sec,
    don't you ? I didn't ask to provide all types existed now, only types you are
    using.
    Anyhow you have been granted with execute privilege for types you are using:
    SQL> conn tau_tll/tau_tll;
    Connected.
    SQL> create or replace type d_period_sec as object (date# date);
      2  /
    Type created.
    SQL> grant execute on d_period_sec to public with grant option;
    Grant succeeded.
    SQL> conn scott/tiger
    Connected.
    SQL> CREATE OR REPLACE TYPE unit_function AS OBJECT (
      2  xi NUMBER,
      3  yi NUMBER,
      4  xe NUMBER,
      5  ye NUMBER,
      6  xm NUMBER,
      7  ym NUMBER,
      8  v NUMBER,
      9  a NUMBER,
    10  f NUMBER,
    11  descr VARCHAR2 (20)
    12  );
    13  /
    Type created.
    SQL> grant execute on unit_function to master;
    Grant succeeded.
    SQL> CREATE OR REPLACE TYPE unit_moving_point AS OBJECT
      2  (
      3  p tau_tll.d_period_sec, -- from user TAU_TLL
      4 
      5  m unit_function
      6  )
      7  /
    Type created.
    SQL> grant execute on unit_moving_point to master;
    Grant succeeded.
    SQL> CREATE OR REPLACE TYPE moving_point_tab AS TABLE OF unit_moving_point;
      2  /
    Type created.
    SQL> grant execute on moving_point_tab to master;
    Grant succeeded.
    SQL> CREATE OR REPLACE TYPE moving_point AS OBJECT (u_tab moving_point_tab);
      2  /
    Type created.
    SQL> grant execute on moving_point to master;
    Grant succeeded.
    SQL> conn master/master
    Connected.
    SQL> CREATE TABLE MPOINTS (
      2  id NUMBER,
      3  mpoint scott.Moving_Point)
      4  NESTED TABLE mpoint.u_tab store as moving_tab;
    Table created.Rgds.

  • MDS: Persist af:tree/ tree table component

    Hi,
    I have dropped a af:tree onto the page, populating data programatically from a bean.
    <af:tree id="favTree" value="#{FavoritesBean.treeModel}"
    var="node" binding="#{FavoritesBean.favTreeBind}"
    initiallyExpanded="true" rowSelection="single">
    <f:facet name="nodeStamp">
    <af:outputText value="#{node.desc}" id="ot3"/>
    </f:facet>
    </af:tree>
    Could anybody suggest how can I persist the Tree component's data across sessions using MDS?
    Thanks,
    Vinod

    Vinod,
    What are you trying to persist, the actual data in the tree or something else? According to [url http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/ad_persist.htm]the documentation (may have changed in 11.1.1.3, haven't checked yet), af:tree doesn't have any built-in support for runtime personalization of the component, but you can implement your own custom user customization as detailed in the same document.
    If you mean something else, please explain.
    John

  • Probleme de telechargement film ( tres tres long voir impossible )

    Bonjour a tous, j'ai un souci avec mon Apple TV deuxième génération, au début cela fonctionner très bien, et depuis quelque temps ca devient impossible de regarder un film sans que ca charge tout le temps.....
    Ayant fait la derniere mise a jour hier ca fonctionne toujours aussi mal ..
    Est-ce un probleme du serveur apple ou autre ?
    De mon coter j'ai rien modifier au niveau de mon insta quand ca marché tres bien
    merci de votre aide

    Même problème ici, suite demande explication auprès d'un vendeur Apple Store, il a répondu que ça venait de ma connexion ! Mort de rire j'ai une connexion de 9 / 10 M suivant les jour, soit au moins 1,5 fois ce qui est nécessaire. Bref je commence à penser que Apple se moque de ses client car 4.99 euros pour un film avec parfois 12h00 de chargement, c'est aussi rapide d'aller louer un film dans un magasin.
    Au fait j'ai un ami anglais qui a exactement le même problème ! (surement sa connexion aussi lol. . .)

  • Mon MacBook Pro bug, il est tres tres lent

    Mon MacBook Pro ne marche plus ou presque. Il est comme gelé. Chaque opération, le moindre clic  prend 15 à 20 mn pour se faire. Et cette rose qui tourne sans cesse.
    Je ne sais pas quoi faire, j'ai déjà redémarré plusieurs fois..
    Le problème à commencé quand j'ai cliquer deux fois sur une application pour l'ouvrir, j'ai eu un message et puis après tout s'est figé, j'ai éteint avec l'interrupteur et ça n'a fait qu'aggraver la situation

    Meme probleme seulement mon bug a commencé lorsque j'ai voulu demarrer mon mac quelques heures apres la derniere utilisation...
    j'essaye de faire ce que tu viens de dire jean marie cependant comme il ne veut pas ouvrir apple
    sais tu donc ce que je peux faire pour le débuger car cela me gene enormement etant donné que je ne travail que par ordinateur et donc que tout mes fichiers sont dedans

  • Classes in javax.faces.tree package

    Which jar in jsf has the javax.faces.tree.Tree class and the TreeFactory interface?
    I'am having jsf-1_1_01 which has jsf-api.jar, jsf-impl.jar and couple of other jars. But none of them have the Tree class. Also i downloaded jwsdp-1.6, this has the same set of jars but none of them have the javax.faces.tree.Tree class.
    Please let me know where can i find the Tree class.

    The following is obsolete ...
    I don't know ehere in the archive that might be, but I downloaded jsf-1.2_04-b07-FCS-src.zip, extracted it and let my favourite search tool look for HtmlSelectOneListbox.java. It isn't there - in no subdir.
    Either I'm too foolish or you are using a different archive ...
    Message was edited by:
    SKuettner

  • Useful Code of the Day:  Hideable Tree Nodes

    Someone posted about how they could selectively hide tree nodes, and I already had this AbstractTreeModel class (which does some things DefaultTreeModel does and some it doesn't) and a concrete subclass for TreeNode objects, so I was thinking how one could do hideable nodes. So I came up with this solution.
    There's 4 classes here:
    - AbstractTreeModel is the base for the concrete TreeNodeTreeModel
    - TreeNodeTreeModel extends AbstractTreeModel to support TreeNodes (DefautlMutableTreeNode, etc.)
    - HideableMutableTreeNode which is a DefautlMutableTreeNode subclass which has a visible field (with is/set methods, of course).
    - HideableTreeModel is the hideable model which is a subclass of TreeNodeTreeModel.
    A HideableMutableTreeNode can be set invisible directly, but the tree still needs to be notified to update. So it's best to use the methods in HideableTreeModel which set a node's visibility which notify the tree of changes accordingly. Methods are also provided to check a full path's visibility or ensure a node including all parent nodes are visible.
    A HideableTreeModel can take any TreeNode class, it doesn't have to be all HideableMutableTreeNodes, but only HideableMutableTreeNodes can be made invisible, of course. Any other TreeNode type would just be considered visible.
    Hiding nodes works basically by making the tree think there's less nodes then there are. And to do this, the node counts and child index search just works by looping thru the parent's children. This has potential perfomance drawbacks of course, since one has to loop thru the node's children to get nodes every time. This could be alleviated by not supporting non-hideable nodes changing the internal maintenance of HideableMutableTreeNode contents. But I'll leave that to whoever really needs it. It shouldn't be a problem if there are are a relatively small set of child nodes in any given parent.
    Also, note that the root node in the model cannot be made invisible, cuz it'd be redundant since JTree can be set to hide the root node.
    // *** HideableTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    * <code>HideableTreeModel</code> is an <code>TreeNodeTreeModel</code>
    * implementation for <code>HideableMutableTreeNode</code> objects.  The
    * model can also take any other <code>javax.swing.tree.TreeNode</code>
    * objects. 
    public class HideableTreeModel extends TreeNodeTreeModel {
          * Creates a new <code>HideableTreeModel</code> object.
          * @param  root  the root node
         public HideableTreeModel(TreeNode root) {
              super(root);
          * Checks if the specified node is visible.  A node can only be
          * hidden if the node is an instance of <code>HideableMutableTreeNode</code>.  <br />
          * <br />
          * Note that this only test the visibility of the specified node, not
          * whether a parent node is visible.  Use <code>isPathToNodeVisible(Object)</code>
          * to check if the full path is visible. 
          * @param  node  the node
          * @param  true if the node is visible, else false
         public boolean isNodeVisible(Object node) {
              if(node != getRoot()) {
                   if(node instanceof HideableMutableTreeNode) {
                        return ((HideableMutableTreeNode)node).isVisible();
              return true;
          * Sets the specified node to be hidden.  A node can only be made hidden
          * if the node is an instance of <code>HideableMutableTreeNode</code>.  <br />
          * <br />
          * Note that this method will notify the tree to reflect any changes to
          * node visibility.  <br />
          * <br />
          * Note that this will not alter the visibility of any nodes in the
          * specified node's path to the root node.  Use
          * <code>ensurePathToNodeVisible(Object)</code> instead to make sure the
          * full path down to that node is visible.  <br />
          * <br />
          * Note that this method will notify the tree to reflect any changes to
          * node visibility. 
          * @param  node  the node
          * @param  v     true for visible, false for hidden
          * @param  true if the node's visibility could actually change, else false
         public boolean setNodeVisible(Object node, boolean v) {
              // can't hide root
              if(node != getRoot()) {
                   if(node instanceof HideableMutableTreeNode) {
                        HideableMutableTreeNode n = (HideableMutableTreeNode)node;
                        // don't fix what ain't broke...
                        if(v != n.isVisible()) {
                             TreeNode parent = n.getParent();
                             if(v) {
                                  // need to get index after showing...
                                  n.setVisible(v);
                                  int index = getIndexOfChild(parent, n);
                                  super.nodeInserted(parent, n, index);
                             } else {
                                  // need to get index before hiding...
                                  int index = getIndexOfChild(parent, n);
                                  n.setVisible(v);
                                  super.nodeRemoved(parent, n, index);
                        return true;
              return false;
          * Checks if the specified node is visible and all nodes above it are
          * visible. 
          * @param  node  the node
          * @param  true if the path is visible, else false
         public boolean isPathToNodeVisible(Object node) {
              Object[] path = getPathToRoot(node);
              for(int i = 0; i < path.length; i++) {
                   if(!isNodeVisible(path)) {
                        return false;
              return true;
         * Sets the specified node and all nodes above it to be visible.
         * Note that this method will notify the tree to reflect any changes to
         * node visibility.
         * @param node the node
         public void ensurePathToNodeVisible(Object node) {
              Object[] path = getPathToRoot(node);
              for(int i = 0; i < path.length; i++) {
                   setNodeVisible(path[i], true);
         * Returns the child of parent at index index in the parent's child array.
         * @param parent the parent node
         * @param index the index
         * @return the child or null if no children
         public Object getChild(Object parent, int index) {
              if(parent instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   for(int i = 0, j = -1; i < p.getChildCount(); i++) {
                        TreeNode pc = (TreeNode)p.getChildAt(i);
                        if(isNodeVisible(pc)) {
                             j++;
                        if(j == index) {
                             return pc;
              return null;
         * Returns the number of children of parent.
         * @param parent the parent node
         * @return the child count
         public int getChildCount(Object parent) {
              int count = 0;
              if(parent instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   for(int i = 0; i < p.getChildCount(); i++) {
                        TreeNode pc = (TreeNode)p.getChildAt(i);
                        if(isNodeVisible(pc)) {
                             count++;
              return count;
         * Returns the index of child in parent.
         * @param parent the parent node
         * @param child the child node
         * @return the index of the child node in the parent
         public int getIndexOfChild(Object parent, Object child) {
              int index = -1;
              if(parent instanceof TreeNode && child instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   TreeNode c = (TreeNode)child;
                   if(isNodeVisible(c)) {
                        index = 0;
                        for(int i = 0; i < p.getChildCount(); i++) {
                             TreeNode pc = (TreeNode)p.getChildAt(i);
                             if(pc.equals(c)) {
                                  return index;
                             if(isNodeVisible(pc)) {
                                  index++;
              return index;
         * Main method for testing.
         * @param args the command-line arguments
         public static void main(String[] args) {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              HideableMutableTreeNode root = new HideableMutableTreeNode("root");
              root.add(new HideableMutableTreeNode("child_1"));
              final HideableMutableTreeNode c2 = new HideableMutableTreeNode("child_2");
              c2.setVisible(false);
              final HideableMutableTreeNode c2a = new HideableMutableTreeNode("child_2_A");
              c2.add(c2a);
              c2.add(new HideableMutableTreeNode("child_2_B"));
              root.add(c2);
              HideableMutableTreeNode c3 = new HideableMutableTreeNode("child_3");
              HideableMutableTreeNode cC = new HideableMutableTreeNode("child_3_C");
              cC.setVisible(false);
              c3.add(cC);
              c3.add(new HideableMutableTreeNode("child_3_D"));
              root.add(c3);
              root.add(new HideableMutableTreeNode("child_4"));
              root.add(new HideableMutableTreeNode("child_5"));
              DefaultMutableTreeNode c6 = new DefaultMutableTreeNode("child_6");
              c6.add(new DefaultMutableTreeNode("child_6_A"));
              c6.add(new DefaultMutableTreeNode("child_6_B"));
              root.add(c6);
              final HideableTreeModel model = new HideableTreeModel(root);
              JTree tree = new JTree(model);
              f.getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
              JButton b = new JButton("toggle");
              b.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        model.setNodeVisible(c2, !model.isNodeVisible(c2));
                        //model.ensurePathToNodeVisible(c2a);
              f.getContentPane().add(b, BorderLayout.SOUTH);
              f.pack();
              f.setSize(300, 500);
              f.show();
    // *** HideableMutableTreeNode ***
    import javax.swing.*;
    import javax.swing.tree.*;
    * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code>
    * implementation that works with <code>HideableTreeModel</code>.
    public class HideableMutableTreeNode extends DefaultMutableTreeNode {
         * The node is visible flag.
         public boolean visible = true;
         * Creates a tree node that has no parent and no children, but which
         * allows children.
         public HideableMutableTreeNode() {
              super();
         * Creates a tree node with no parent, no children, but which allows
         * children, and initializes it with the specified user object.
         * @param userObject - an Object provided by the user that
         * constitutes the node's data
         public HideableMutableTreeNode(Object userObject) {
              super(userObject);
         * Creates a tree node with no parent, no children, initialized with the
         * specified user object, and that allows children only if specified.
         * @param userObject - an Object provided by the user that
         * constitutes the node's data
         * @param allowsChildren - if true, the node is allowed to have child
         * nodes -- otherwise, it is always a leaf node
         public HideableMutableTreeNode(Object userObject, boolean allowsChildren) {
              super(userObject, allowsChildren);
         * Checks if the node is visible.
         * @return true if the node is visible, else false
         public boolean isVisible() {
              return this.visible;
         * Sets if the node is visible.
         * @param v true if the node is visible, else false
         public void setVisible(boolean v) {
              this.visible = v;
    // *** TreeNodeTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    * <code>TreeNodeTreeModel</code> is an <code>AbstractTreeModel</code>
    * implementation for <code>javax.swing.tree.TreeNode</code> objects.
    public class TreeNodeTreeModel extends AbstractTreeModel {
         * Creates a new <code>TreeNodeTreeModel</code> object.
         * @param root the root node
         public TreeNodeTreeModel(TreeNode root) {
              super();
              setRoot(root);
         * Returns the parent of the child node.
         * @param node the child node
         * @return the parent or null if root
         public Object getParent(Object node) {
              if(node != getRoot() && (node instanceof TreeNode)) {
                   return ((TreeNode)node).getParent();
              return null;
         * Returns the child of parent at index index in the parent's child array.
         * @param parent the parent node
         * @param index the index
         * @return the child or null if no children
         public Object getChild(Object parent, int index) {
              if(parent instanceof TreeNode) {
                   return ((TreeNode)parent).getChildAt(index);
              return null;
         * Returns the number of children of parent.
         * @param parent the parent node
         * @return the child count
         public int getChildCount(Object parent) {
              if(parent instanceof TreeNode) {
                   return ((TreeNode)parent).getChildCount();
              return 0;
         * Returns the index of child in parent.
         * @param parent the parent node
         * @param child the child node
         * @return the index of the child node in the parent
         public int getIndexOfChild(Object parent, Object child) {
              if(parent instanceof TreeNode && child instanceof TreeNode) {
                   return ((TreeNode)parent).getIndex((TreeNode)child);
              return -1;
         * Returns true if node is a leaf.
         * @param node the node
         * @return true if the node is a leaf
         public boolean isLeaf(Object node) {
              if(node instanceof TreeNode) {
                   return ((TreeNode)node).isLeaf();
              return true;
         * Main method for testing.
         * @param args the command-line arguments
         public static void main(String[] args) {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
              root.add(new DefaultMutableTreeNode("child_1"));
              DefaultMutableTreeNode c2 = new DefaultMutableTreeNode("child_2");
              c2.add(new DefaultMutableTreeNode("child_2_A"));
              c2.add(new DefaultMutableTreeNode("child_2_B"));
              root.add(c2);
              root.add(new DefaultMutableTreeNode("child_3"));
              root.add(new DefaultMutableTreeNode("child_4"));
              JTree tree = new JTree(new TreeNodeTreeModel(root));
              f.getContentPane().add(new JScrollPane(tree));
              f.pack();
              f.setSize(300, 500);
              f.show();
    // *** AbstractTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    public abstract class AbstractTreeModel implements TreeModel {
         * The list of tree model listeners.
         private Vector modelListeners = new Vector();
         * The root object of the tree.
         private Object root = null;
         * Basic no-op constructor.
         public AbstractTreeModel() {
         * Gets the root object of the tree.
         * @return the root object
         public Object getRoot() {
              return this.root;
         * Sets the root object of the tree.
         * @param r the root object
         protected void setRoot(Object r) {
              this.root = r;
         * Gets the path to the root node for the specified object.
         * @param node the root node
         * @return the path to the object or <CODE>null</CODE>
         public Object[] getPathToRoot(Object node) {
              return getPathToRoot(node, 0);
         * Gets the path to the root node for the specified object.
         * @param node the root node
         * @param i the current index
         * @return the path to the object or <CODE>null</CODE>
         private Object[] getPathToRoot(Object node, int i) {
              Object anode[];
              if(node == null) {
                   if(i == 0) {
                        return null;
                   anode = new Object[i];
              } else {
                   i++;
                   if(node == getRoot()) {
                        anode = new Object[i];
                   } else {
                        anode = getPathToRoot(getParent(node), i);
                   anode[anode.length - i] = node;
              return anode;
         * Gets the parent object of the specified object. This method is not
         * part of the <code>javax.swing.tree.TreeModel</code> interface, but is
         * required to support the <code>getPathToRoot(Object)</code> method,
         * which is widely used in this class. Therefore, it is important to
         * correctly implement this method.
         * @param obj the object
         * @parma the parent object or null if no parent or invalid object
         protected abstract Object getParent(Object obj);
         * Adds a listener for the <CODE>TreeModelEvent</CODE> posted after the
         * tree changes.
         * @param l the tree model listener
         public void addTreeModelListener(TreeModelListener l) {
              modelListeners.addElement(l);
         * Removes a listener previously added with addTreeModelListener().
         * @param l the tree model listener
         public void removeTreeModelListener(TreeModelListener l) {
              modelListeners.removeElement(l);
         * Forces the tree to reload. This is useful when many changes occur
         * under the root node in the tree structure.
         * <b>NOTE:</b> This will cause the tree to be collapsed. To maintain
         * the expanded nodes, see the <code>getExpandedPaths(JTree)</code>
         * and <code>expandPaths(JTree, ArrayList)</code> methods.
         * @see #getExpandedPaths(JTree)
         * @see #expandPaths(JTree, ArrayList)
         public void reload() {
              reload(getRoot());
         * Forces the tree to repaint. This is useful when many changes occur
         * under a specific node in the tree structure.
         * <b>NOTE:</b> This will cause the tree to be collapsed below the
         * updated node.
         * @param node the node that changed
         public void reload(Object node) {
              if(node != null) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   fireTreeStructureChanged(new TreeModelEvent(this, tp));
         * Messaged when the user has altered the value for the item identified
         * by <CODE>path</CODE> to <CODE>newValue</CODE>.
         * @param path the path to the changed object
         * @param newValue the new value
         public void valueForPathChanged(TreePath path, Object newValue) {
              nodeChanged(path.getLastPathComponent());
         * Notifies the tree that nodes were inserted. The index is looked up
         * automatically.
         * @param node the parent node
         * @param child the inserted child node
         public void nodeInserted(Object node, Object child) {
              nodeInserted(node, child, -1);
         * Notifies the tree that nodes were inserted.
         * @param node the parent node
         * @param child the inserted child node
         * @param index the index of the child
         public void nodeInserted(Object node, Object child, int index) {
              if(index < 0) {
                   index = getIndexOfChild(node, child);
              if(node != null && child != null && index >= 0) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   int[] ai = { index };
                   Object[] ac = { child };
                   fireTreeNodesInserted(new TreeModelEvent(this, tp, ai, ac));
         * Notifies the tree that nodes were removed. The index is required
         * since by this point, the object will no longer be in the tree.
         * @param node the parent node
         * @param child the removed child node
         * @param index the index of the child
         public void nodeRemoved(Object node, Object child, int index) {
              if(node != null && child != null && index >= 0) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   int[] ai = { index };
                   Object[] ac = { child };
                   fireTreeNodesRemoved(new TreeModelEvent(this, tp, ai, ac));
         * Notifies the tree that a node was changed.
         * @param node the changed node
         public void nodeChanged(Object node) {
              if(node != null) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   fireTreeNodesChanged(new TreeModelEvent(this, tp, null, null));
         * Fires "tree nodes changed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesChanged(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesChanged(event);
         * Fires "tree nodes inserted" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesInserted(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesInserted(event);
         * Fires "tree nodes removed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesRemoved(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesRemoved(event);
         * Fires "tree structure changed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeStructureChanged(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeStructureChanged(event);
         * Records the list of currently expanded paths in the specified tree.
         * This method is meant to be called before calling the
         * <code>reload()</code> methods to allow the tree to store the paths.
         * @param tree the tree
         * @param pathlist the list of expanded paths
         public ArrayList getExpandedPaths(JTree tree) {
              ArrayList expandedPaths = new ArrayList();
              addExpandedPaths(tree, tree.getPathForRow(0), expandedPaths);
              return expandedPaths;
         * Adds the expanded descendants of the specifed path in the specified
         * tree to the internal expanded list.
         * @param tree the tree
         * @param path the path
         * @param pathlist the list of expanded paths
         private void addExpandedPaths(JTree tree, TreePath path, ArrayList pathlist) {
              Enumeration enum = tree.getExpandedDescendants(path);
              while(enum.hasMoreElements()) {
                   TreePath tp = (TreePath)enum.nextElement();
                   pathlist.add(tp);
                   addExpandedPaths(tree, tp, pathlist);
         * Re-expands the expanded paths in the specified tree. This method is
         * meant to be called before calling the <code>reload()</code> methods
         * to allow the tree to store the paths.
         * @param tree the tree
         * @param pathlist the list of expanded paths
         public void expandPaths(JTree tree, ArrayList pathlist) {
              for(int i = 0; i < pathlist.size(); i++) {
                   tree.expandPath((TreePath)pathlist.get(i));

    Hey
    I'm not trying to show anyone up here, but having just built a tree model for displaying an XML document in a tree, I thought this seemed like a neat exercise.
    I implemented this very differently from the @OP. I only have one class, HiddenNodeTreeModel. All the hidden node data is stored in the model itself in my class. The advantage of what I've created is it will work with any TreeModel. The disadvantage is that I think it's not going to be very scalable - the additional computing to get the number of child nodes and to adjust indexes is heavy. So if you need a scalable solution definitely don't use this.
    Anyway here you go
    HiddenNodeTreeModel.java
    ======================
    package tjacobs.ui.tree;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Iterator;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JTree;
    import javax.swing.event.TreeModelListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import tjacobs.ui.WindowUtilities;
    public class HiddenNodeTreeModel implements TreeModel {
         TreeModel mModel;
         ArrayList<Object> mHidden = new ArrayList<Object>();
         public HiddenNodeTreeModel (TreeModel model) {
              mModel = model;
         public void addTreeModelListener(TreeModelListener arg0) {
              mModel.addTreeModelListener(arg0);
         private ArrayList<Integer> getHiddenChildren(Object parent) {
              ArrayList<Integer> spots = new ArrayList<Integer>();
              Iterator _i = mHidden.iterator();
              while (_i.hasNext()) {
                   Object hidden = _i.next();
                   int idx = mModel.getIndexOfChild(parent, hidden);
                   if (idx != -1) {
                        spots.add(idx);
              return spots;
         public Object getChild(Object arg0, int index) {
              ArrayList<Integer> spots = getHiddenChildren(arg0);
              Collections.sort(spots);
              Iterator<Integer> _i = spots.iterator();
              while (_i.hasNext()) {
                   int num = _i.next();
                   if (num <= index) {
                        index++;
              return mModel.getChild(arg0, index);
         public int getChildCount(Object arg0) {
              ArrayList list = getHiddenChildren(arg0);
              System.out.println("size = " + list.size());
              return mModel.getChildCount(arg0) - list.size();
         public int getIndexOfChild(Object arg0, Object arg1) {
              int index = mModel.getIndexOfChild(arg0, arg1);
              ArrayList<Integer> spots = getHiddenChildren(arg0);
              Collections.sort(spots);
              Iterator<Integer> _i = spots.iterator();
              int toSub = 0;
              while (_i.hasNext()) {
                   int num = _i.next();
                   if (num <= index) {
                        toSub++;
              return index - toSub;
         public Object getRoot() {
              // TODO Auto-generated method stub
              return mModel.getRoot();
         public boolean isLeaf(Object arg0) {
              // TODO Auto-generated method stub
              return mModel.isLeaf(arg0);
         public void removeTreeModelListener(TreeModelListener arg0) {
              mModel.removeTreeModelListener(arg0);
         public void valueForPathChanged(TreePath arg0, Object arg1) {
              mModel.valueForPathChanged(arg0, arg1);
         public void hideNode(Object node) {
              if (node instanceof TreePath) {
                   node = ((TreePath)node).getLastPathComponent();
              mHidden.add(node);
         public void showNode(Object node) {
              mHidden.remove(node);
         public void showAll() {
              mHidden.clear();
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              DefaultMutableTreeNode A = new DefaultMutableTreeNode("A");
              DefaultMutableTreeNode B = new DefaultMutableTreeNode("B");
              DefaultMutableTreeNode C = new DefaultMutableTreeNode("C");
              DefaultMutableTreeNode D = new DefaultMutableTreeNode("D");
              DefaultMutableTreeNode E = new DefaultMutableTreeNode("E");
              DefaultMutableTreeNode F = new DefaultMutableTreeNode("F");
              A.add(B);
              B.add(C);
              B.add(D);
              B.add(E);
              E.add(F);
              DefaultTreeModel model = new DefaultTreeModel(A);
              final HiddenNodeTreeModel hmodel = new HiddenNodeTreeModel(model);
              final JTree tree = new JTree(hmodel);
              JFrame jf = new JFrame("HiddenNodeTreeModel Test");
              jf.add(tree);
              JMenuBar bar = new JMenuBar();
              jf.setJMenuBar(bar);
              JMenu menu = new JMenu("Options");
              bar.add(menu);
              final JMenuItem hide = new JMenuItem("Hide");
              final JMenuItem show = new JMenuItem("ShowAll");
              menu.add(hide);
              menu.add(show);
              ActionListener al = new ActionListener() {
                   public void actionPerformed(ActionEvent ae) {
                        if (ae.getSource() == hide) {
                             hmodel.hideNode(tree.getSelectionPath());
                             tree.updateUI();
                        else {
                             hmodel.showAll();
                             tree.updateUI();
              hide.addActionListener(al);
              show.addActionListener(al);
              jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              jf.setBounds(100,100,100,100);
              jf.setVisible(true);
    }

  • Help with building a JTree using tree node and node renderers

    Hi,
    I am having a few problems with JTree's. basically I want to build JTree from a web spider. The webspide searches a website checking links and stores the current url that is being processed as a string in the variable msg. I wan to use this variable to build a JTree in a new class and then add it to my GUI. I have created a tree node class and a renderer node class, these classes are built fine. can someone point me in the direction for actually using these to build my tree in a seperate class and then displaying it in a GUI class?
    *nodeRenderer.java
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.*;
    import java.net.*;
    public class nodeRenderer extends DefaultTreeCellRenderer
                                       implements TreeCellRenderer
    public static Icon icon= null;
    public nodeRenderer() {
    icon = new ImageIcon(getClass().getResource("icon.gif"));
    public Component getTreeCellRendererComponent(
    JTree tree,
    Object value,
    boolean sel,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus) {
    super.getTreeCellRendererComponent(
    tree, value, sel,
    expanded, leaf, row,
    hasFocus);
    treeNode node = (treeNode)(((DefaultMutableTreeNode)value).getUserObject());
    if(icon != null) // set a custom icon
    setOpenIcon(icon);
    setClosedIcon(icon);
    setLeafIcon(icon);
         return this;
    *treeNode.java
    *this is the class to represent a node
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.util.*;
    import java.net.*;
    * Class used to hold information about a web site that has
    * been searched by the spider class
    public class treeNode
    *Url from the WebSpiderController Class
    *that is currently being processed
    public String msg;
    treeNode(String urlText)
         msg = urlText;
    String getUrlText()
         return msg;
    //gui.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class gui extends JFrame implements Runnable
         *declare variable, boolean
         *thread, a object and a center
         *pane
         protected URL urlInput;
         protected Thread bgThread;
         protected boolean run = false;
         protected WebSpider webSpider;
         public gui()
              *create the gui here
              setTitle("Testing Tool");
         setSize(600,600);
         //add Buttons to the tool bar
         start.setText("Start");
         start.setActionCommand("Start");
         toolBar.add(start);
         ButtonListener startListener = new ButtonListener();
              start.addActionListener(startListener);
              cancel.setText("Cancel");
         cancel.setActionCommand("Cancel");
         toolBar.add(cancel);
         ButtonListener cancelListener = new ButtonListener();
              cancel.addActionListener(cancelListener);
              close.setText("Close");
         close.setActionCommand("Close");
         toolBar.add(close);
         ButtonListener closeListener = new ButtonListener();
              close.addActionListener(closeListener);
              //creat a simple form
              urlLabel.setText("Enter URL:");
              urlLabel.setBounds(100,36,288,24);
              formTab.add(urlLabel);
              url.setBounds(170,36,288,24);
              formTab.add(url);
              current.setText("Currently Processing: ");
              current.setBounds(100,80,288,24);
              formTab.add(current);
         //add scroll bars to the error messages screen and website structure
         errorPane.setAutoscrolls(true);
         errorPane.setHorizontalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
         errorPane.setVerticalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         errorPane.setOpaque(true);
         errorTab.add(errorPane);
         errorPane.setBounds(0,0,580,490);
         errorText.setEditable(false);
         errorPane.getViewport().add(errorText);
         errorText.setBounds(0,0,600,550);
         treePane.setAutoscrolls(true);
         treePane.setHorizontalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
         treePane.setVerticalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         treePane.setOpaque(true);
         treeTab.add(treePane);
         treePane.setBounds(0,0,580,490);
         treeText.setEditable(false);
         treePane.getViewport().add(treeText);
         treeText.setBounds(0,0,600,550);
         //create the tabbed window           
    centerPane.setBorder(new javax.swing.border.EtchedBorder());
    formTab.setLayout(null);
    errorTab.setLayout(null);
    treeTab.setLayout(null);
    centerPane.addTab("Search Parameters", formTab);
    centerPane.addTab("Error Messages", errorTab);
    centerPane.addTab("Website Structure", treeTab);
              //add the tool bar and tabbed pane
              getContentPane().add(toolBar, java.awt.BorderLayout.NORTH);
    getContentPane().add(centerPane, java.awt.BorderLayout.CENTER);                    
              *create the tool bar pane, a center pane, add the buttons,
              *labels, tabs, a text field for user input here
              javax.swing.JPanel toolBar = new javax.swing.JPanel();
              javax.swing.JButton start = new javax.swing.JButton();
              javax.swing.JButton cancel = new javax.swing.JButton();
              javax.swing.JButton close = new javax.swing.JButton();      
              javax.swing.JTabbedPane centerPane = new javax.swing.JTabbedPane();
              javax.swing.JPanel formTab = new javax.swing.JPanel();
              javax.swing.JLabel urlLabel = new javax.swing.JLabel();
              javax.swing.JLabel current = new javax.swing.JLabel();
              javax.swing.JTextField url = new javax.swing.JTextField();
              javax.swing.JPanel errorTab = new javax.swing.JPanel();
              javax.swing.JTextArea errorText = new javax.swing.JTextArea();
              javax.swing.JScrollPane errorPane = new javax.swing.JScrollPane();
              javax.swing.JPanel treeTab = new javax.swing.JPanel();
              javax.swing.JTextArea treeText = new javax.swing.JTextArea();
              javax.swing.JScrollPane treePane = new javax.swing.JScrollPane();
              javax.swing.JTree searchTree = new javax.swing.JTree();
              *show the gui
              public static void main(String args[])
              (new gui()).setVisible(true);
         *listen for the button presses and set the
         *boolean flag depending on which button is pressed
         class ButtonListener implements ActionListener
              public void actionPerformed(ActionEvent event)
                   Object object = event.getSource();
                   if (object == start)
                        run = true;
                        startActionPerformed(event);
                   if (object == cancel)
                        run = false;
                        startActionPerformed(event);
                   if (object == close)
                        System.exit(0);
         *this method is called when the start or
         *cancel button is pressed.
         void startActionPerformed (ActionEvent event)
              if (run == true && bgThread == null)
                   bgThread = new Thread(this);
                   bgThread.start();
              if (run == false && bgThread != null)
                   webSpider.cancel();
         *this mehtod will start the background thred.
         *the background thread is required so that the
         *GUI is still displayed
         public void run()
              try
                   webSpider = new WebSpider(this);
                   webSpider.clear();
                   urlInput = new URL(url.getText());
                   webSpider.addURL(urlInput);
                   webSpider.run();
                   bgThread=null;
              catch (MalformedURLException e)
                   addressError addErr = new addressError();
                   addErr.addMsg = "URL ERROR - PLEASE CHECK";
                   SwingUtilities.invokeLater(addErr);
              *this method is called by the web spider
              *once a url is found. Validation of navigation
              *happens here.
              public boolean urlFound(URL urlInput,URL url)
                   CurrentlyProcessing pro = new CurrentlyProcessing();
              pro.msg = url.toString();
              SwingUtilities.invokeLater(pro);
              if (!testLink(url))
                        navigationError navErr = new navigationError();
                        navErr.navMsg = "Broken Link "+url+" caused on "+urlInput+"\n";
                        return false;
              if (!url.getHost().equalsIgnoreCase(urlInput.getHost()))
                   return false;
              else
                   return true;
              *this method is called internally to check
         *that a link works
              protected boolean testLink(URL url)
              try
                   URLConnection connection = url.openConnection();
                   connection.connect();
                   return true;
              catch (IOException e)
                   return false;
         *this method is called when an error is
         *found.
              public void URLError(URL url)
              *this method is called when an email
              *address is found
              public void emailFound(String email)
              /*this method will update any errors found inc
              *address errors and broken links
              class addressError implements Runnable
                   public String addMsg;
                   public void run()
                        errorText.append(addMsg);
                        current.setText("Currently Processing: "+ addMsg);
              class navigationError implements Runnable
                   public String navMsg;
                   public void run()
                        errorText.append(navMsg);
              *this method will update the currently
              *processing field on the GUI
              class CurrentlyProcessing implements Runnable
              public String msg;
              public void run()
                   current.setText("Currently Processing: " + msg );
    //webspider.java
    import java.util.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import javax.swing.tree.*;
    import javax.swing.*;
    *this class implements the spider.
    public class WebSpider extends HTMLEditorKit
         *make a collection of the URL's
         protected Collection urlErrors = new ArrayList(3);
         protected Collection urlsWaiting = new ArrayList(3);
         protected Collection urlsProcessed = new ArrayList(3);
         //report URL's to this class
         protected gui report;
         *this flag will indicate whether the process
         *is to be cancelled
         protected boolean cancel = false;
         *The constructor
         *report the urls to the wui class
         public WebSpider(gui report)
         this.report = report;
         *get the urls from the above declared
         *collections
         public Collection getUrlErrors()
         return urlErrors;
         public Collection getUrlsWaiting()
         return urlsWaiting;
         public Collection getUrlsProcessed()
         return urlsProcessed;
         * Clear all of the collections.
         public void clear()
         getUrlErrors().clear();
         getUrlsWaiting().clear();
         getUrlsProcessed().clear();
         *Set a flag that will cause the begin
         *method to return before it is done.
         public void cancel()
         cancel = true;
         *add the entered url for porcessing
         public void addURL(URL url)
         if (getUrlsWaiting().contains(url))
              return;
         if (getUrlErrors().contains(url))
              return;
         if (getUrlsProcessed().contains(url))
              return;
         /*WRITE TO LOG FILE*/
         log("Adding to workload: " + url );
         getUrlsWaiting().add(url);
         *process a url
         public void processURL(URL url)
         try
              /*WRITE TO LOGFILE*/
              log("Processing: " + url );
              // get the URL's contents
              URLConnection connection = url.openConnection();
              if ((connection.getContentType()!=null) &&
         !connection.getContentType().toLowerCase().startsWith("text/"))
              getUrlsWaiting().remove(url);
              getUrlsProcessed().add(url);
              log("Not processing because content type is: " +
         connection.getContentType() );
                   return;
         // read the URL
         InputStream is = connection.getInputStream();
         Reader r = new InputStreamReader(is);
         // parse the URL
         HTMLEditorKit.Parser parse = new HTMLParse().getParser();
         parse.parse(r,new Parser(url),true);
    catch (IOException e)
         getUrlsWaiting().remove(url);
         getUrlErrors().add(url);
         log("Error: " + url );
         report.URLError(url);
         return;
    // mark URL as complete
    getUrlsWaiting().remove(url);
    getUrlsProcessed().add(url);
    log("Complete: " + url );
    *start the spider
    public void run()
    cancel = false;
    while (!getUrlsWaiting().isEmpty() && !cancel)
         Object list[] = getUrlsWaiting().toArray();
         for (int i=0;(i<list.length)&&!cancel;i++)
         processURL((URL)list);
    * A HTML parser callback used by this class to detect links
    protected class Parser extends HTMLEditorKit.ParserCallback
    protected URL urlInput;
    public Parser(URL urlInput)
    this.urlInput = urlInput;
    public void handleSimpleTag(HTML.Tag t,MutableAttributeSet a,int pos)
    String href = (String)a.getAttribute(HTML.Attribute.HREF);
    if((href==null) && (t==HTML.Tag.FRAME))
    href = (String)a.getAttribute(HTML.Attribute.SRC);
    if (href==null)
    return;
    int i = href.indexOf('#');
    if (i!=-1)
    href = href.substring(0,i);
    if (href.toLowerCase().startsWith("mailto:"))
    report.emailFound(href);
    return;
    handleLink(urlInput,href);
    public void handleStartTag(HTML.Tag t,MutableAttributeSet a,int pos)
    handleSimpleTag(t,a,pos); // handle the same way
    protected void handleLink(URL urlInput,String str)
    try
         URL url = new URL(urlInput,str);
    if (report.urlFound(urlInput,url))
    addURL(url);
    catch (MalformedURLException e)
    log("Found malformed URL: " + str);
    *log the information of the spider
    public void log(String entry)
    System.out.println( (new Date()) + ":" + entry );
    I have a seperate class for parseing the HTML. Any help would be greatly appreciated
    mrv

    Hi Sorry to be a pain again,
    I have re worked the gui class so it looks like this now:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class gui extends JFrame implements Runnable
         *declare variable, boolean
         *thread, a object and a center
         *pane
         protected URL urlInput;
         protected Thread bgThread;
         protected boolean run = false;
         protected WebSpider webSpider;
         public String msgInfo;
         public String brokenUrl;
         public String goodUrl;
         public String deadUrl;
         protected DefaultMutableTreeNode rootNode;
    protected DefaultTreeModel treeModel;
         public gui()
              *create the gui here
              setTitle("Testing Tool");
         setSize(600,600);
         //add Buttons to the tool bar
         start.setText("Start");
         start.setActionCommand("Start");
         toolBar.add(start);
         ButtonListener startListener = new ButtonListener();
              start.addActionListener(startListener);
              cancel.setText("Cancel");
         cancel.setActionCommand("Cancel");
         toolBar.add(cancel);
         ButtonListener cancelListener = new ButtonListener();
              cancel.addActionListener(cancelListener);
              close.setText("Close");
         close.setActionCommand("Close");
         toolBar.add(close);
         ButtonListener closeListener = new ButtonListener();
              close.addActionListener(closeListener);
              //creat a simple form
              urlLabel.setText("Enter URL:");
              urlLabel.setBounds(100,36,288,24);
              formTab.add(urlLabel);
              url.setBounds(170,36,288,24);
              formTab.add(url);
              current.setText("Currently Processing: ");
              current.setBounds(100,80,288,24);
              formTab.add(current);
         //add scroll bars to the error messages screen and website structure
         errorPane.setAutoscrolls(true);
         errorPane.setHorizontalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
         errorPane.setVerticalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         errorPane.setOpaque(true);
         errorTab.add(errorPane);
         errorPane.setBounds(0,0,580,490);
         errorText.setEditable(false);
         errorPane.getViewport().add(errorText);
         errorText.setBounds(0,0,600,550);
         treePane.setAutoscrolls(true);
         treePane.setHorizontalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
         treePane.setVerticalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         treePane.setOpaque(true);
         treeTab.add(treePane);
         treePane.setBounds(0,0,580,490);
         treeText.setEditable(false);
         treePane.getViewport().add(treeText);
         treeText.setBounds(0,0,600,550);
         //JTree
         // NEW CODE
         rootNode = new DefaultMutableTreeNode("Root Node");
         treeModel = new DefaultTreeModel(rootNode);
         treeModel.addTreeModelListener(new MyTreeModelListener());
         tree = new JTree(treeModel);
         tree.setEditable(true);
         tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);
         treeText.add(tree);
         //create the tabbed window           
    centerPane.setBorder(new javax.swing.border.EtchedBorder());
    formTab.setLayout(null);
    errorTab.setLayout(null);
    treeTab.setLayout(null);
    centerPane.addTab("Search Parameters", formTab);
    centerPane.addTab("Error Messages", errorTab);
    centerPane.addTab("Website Structure", treeTab);
              //add the tool bar and tabbed pane
              getContentPane().add(toolBar, java.awt.BorderLayout.NORTH);
    getContentPane().add(centerPane, java.awt.BorderLayout.CENTER);     
              *create the tool bar pane, a center pane, add the buttons,
              *labels, tabs, a text field for user input here
              javax.swing.JPanel toolBar = new javax.swing.JPanel();
              javax.swing.JButton start = new javax.swing.JButton();
              javax.swing.JButton cancel = new javax.swing.JButton();
              javax.swing.JButton close = new javax.swing.JButton();      
              javax.swing.JTabbedPane centerPane = new javax.swing.JTabbedPane();
              javax.swing.JPanel formTab = new javax.swing.JPanel();
              javax.swing.JLabel urlLabel = new javax.swing.JLabel();
              javax.swing.JLabel current = new javax.swing.JLabel();
              javax.swing.JTextField url = new javax.swing.JTextField();
              javax.swing.JPanel errorTab = new javax.swing.JPanel();
              javax.swing.JTextArea errorText = new javax.swing.JTextArea();
              javax.swing.JScrollPane errorPane = new javax.swing.JScrollPane();
              javax.swing.JPanel treeTab = new javax.swing.JPanel();
              javax.swing.JTextArea treeText = new javax.swing.JTextArea();
              javax.swing.JScrollPane treePane = new javax.swing.JScrollPane();
              javax.swing.JTree tree = new javax.swing.JTree();
              *show the gui
              public static void main(String args[])
              (new gui()).setVisible(true);
         *listen for the button presses and set the
         *boolean flag depending on which button is pressed
         class ButtonListener implements ActionListener
              public void actionPerformed(ActionEvent event)
                   Object object = event.getSource();
                   if (object == start)
                        run = true;
                        startActionPerformed(event);
                   if (object == cancel)
                        run = false;
                        startActionPerformed(event);
                   if (object == close)
                        System.exit(0);
         *this method is called when the start or
         *cancel button is pressed.
         void startActionPerformed (ActionEvent event)
              if (run == true && bgThread == null)
                   bgThread = new Thread(this);
                   bgThread.start();
                   //new line of code
                   treeText.addObject(msgInfo);
              if (run == false && bgThread != null)
                   webSpider.cancel();
         *this mehtod will start the background thred.
         *the background thread is required so that the
         *GUI is still displayed
         public void run()
              try
                   webSpider = new WebSpider(this);
                   webSpider.clear();
                   urlInput = new URL(url.getText());
                   webSpider.addURL(urlInput);
                   webSpider.run();
                   bgThread = null;
              catch (MalformedURLException e)
                   addressError addErr = new addressError();
                   addErr.addMsg = "URL ERROR - PLEASE CHECK";
                   SwingUtilities.invokeLater(addErr);
              *this method is called by the web spider
              *once a url is found. Validation of navigation
              *happens here.
              public boolean urlFound(URL urlInput,URL url)
                   CurrentlyProcessing pro = new CurrentlyProcessing();
              pro.msg = url.toString();
              SwingUtilities.invokeLater(pro);
              if (!testLink(url))
                        navigationError navErr = new navigationError();
                        navErr.navMsg = "Broken Link "+url+" caused on "+urlInput+"\n";
                        brokenUrl = url.toString();
                        return false;
              if (!url.getHost().equalsIgnoreCase(urlInput.getHost()))
                   return false;
              else
                   return true;
              *this method is returned if there is no link
              *on a web page, e.g. there us a dead end
              public void urlNotFound(URL urlInput)
                        deadEnd dEnd = new deadEnd();
                        dEnd.dEMsg = "No links on "+urlInput+"\n";
                        deadUrl = urlInput.toString();               
              *this method is called internally to check
         *that a link works
              protected boolean testLink(URL url)
              try
                   URLConnection connection = url.openConnection();
                   connection.connect();
                   goodUrl = url.toString();
                   return true;
              catch (IOException e)
                   return false;
         *this method is called when an error is
         *found.
              public void urlError(URL url)
              *this method is called when an email
              *address is found
              public void emailFound(String email)
              /*this method will update any errors found inc
              *address errors and broken links
              class addressError implements Runnable
                   public String addMsg;
                   public void run()
                        current.setText("Currently Processing: "+ addMsg);
                        errorText.append(addMsg);
              class navigationError implements Runnable
                   public String navMsg;
                   public void run()
                        errorText.append(navMsg);
              class deadEnd implements Runnable
                   public String dEMsg;
                   public void run()
                        errorText.append(dEMsg);
              *this method will update the currently
              *processing field on the GUI
              public class CurrentlyProcessing implements Runnable
                   public String msg;
              //new line
              public String msgInfo = msg;
              public void run()
                   current.setText("Currently Processing: " + msg );
         * NEW CODE
         * NEED THIS CODE SOMEWHERE
         * treeText.addObject(msgInfo);
         public DefaultMutableTreeNode addObject(Object child)
         DefaultMutableTreeNode parentNode = null;
         TreePath parentPath = tree.getSelectionPath();
         if (parentPath == null)
         parentNode = rootNode;
         else
         parentNode = (DefaultMutableTreeNode)
    (parentPath.getLastPathComponent());
         return addObject(parentNode, child, true);
         public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
    Object child)
         return addObject(parent, child, false);
         public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
         Object child,boolean shouldBeVisible)
         DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child);
         if (parent == null)
         parent = rootNode;
         treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
         if (shouldBeVisible)
         tree.scrollPathToVisible(new TreePath(childNode.getPath()));
              return childNode;
         public class MyTreeModelListener implements TreeModelListener
              public void treeNodesChanged (TreeModelEvent e)
                   DefaultMutableTreeNode node;
                   node = (DefaultMutableTreeNode)
                   (e.getTreePath().getLastPathComponent());
                   try
                        int index = e.getChildIndices()[0];
                        node = (DefaultMutableTreeNode)
                        (node.getChildAt(index));
                   catch (NullPointerException exc)
              public void treeNodesInserted(TreeModelEvent e)
              public void treeStructureChanged(TreeModelEvent e)
              public void treeNodesRemoved(TreeModelEvent e)
    I beleive that this line of code is required:
    treeText.addObject(msgInfo);
    I have placed it where the action events start the spider, but i keep getting this error:
    cannot resolve symbol
    symbol : method addObject (java.lang.String)
    location: class javax.swing.JTextArea
    treeText.addObject(msgInfo);
    Also the jtree is not showing the window that I want it to and I am not too sure why. could you have a look to see why? i think it needs a fresh pair of eyes.
    Many thanks
    MrV

  • Determine if mouse is over tree node

    hi.
    I recently added some code from this forum on
    highlighting a node when the mouse is over it.
    I am taking this futher and setting a Border around the nodehowever it draws a border around every node.
    I want to only draw the border when the mouse is over the node.
    the example i got does this to set the foreground
    ((JLabel)result).setForeground(Color.red);
    i do this to set the border
    ((JLabel)result).setBorder
    (BorderFactory.createLineBorder(Color.black));
    i ve tried getting the positions of both the mouse and the jlabel but am having trouble determining if the position of the mouse is within the position of the node in the tree.
    Ive used methods like the contains method but it doesnt work for me . can anyone give me a hint as to how to see if the points of the mouse are on the Jlabel?

    This is very close to your solution. Last month, I implement ToolTip Text on every Tree Node so when Mouse goes on to the Node, It shows the Tool Tip Text. Have a look at this code and try to change it accordingly.
    This code is in the Constructor in your class.
    tree.setCellRenderer(new IDETreeCellRenderer());
    tree.setToolTipText("");Class: IDETreeCellRenderer - Cell Renderer for the Tree
    package tv.izone.ide.tree;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import tv.izone.core.*;
    import tv.izone.ide.guiutilities.*;
    import tv.izone.izml.data.*;
    public class IDETreeCellRenderer
        extends DefaultTreeCellRenderer {
       DefaultTreeCellRenderer label;
        * Override TreeCellRendererComponent, used for changing Tree Node for comments.
        * @param tree Tree to be used
        * @param value Value of the Node
        * @param selected true, if selected
        * @param expanded true, if expanded
        * @param leaf true, if it is a leaf
        * @param row Row Number
        * @param hasFocus True, if has Focus
        * @return Component, Tree
       public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
                                      boolean leaf, int row, boolean hasFocus) {
          try {
          label = (DefaultTreeCellRenderer)super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row,
                                                      hasFocus);
          label.setToolTipText(dataObject.getToolTipText());
    // Instead of setToolTipText(), try setBackgroundColor() or setBorder()
         return label;
          } catch (Exception ex) {
          // NullPointerException, usually comes at the start of the Application
          // when the Tree is empty.
          return this;
    }Hope this Helps
    Regards
    Raheel

  • [JPF/NetUI]NetUI tree issue---Urgent

    Gurus, :)
    I had an issue when i used the NetUI true in my project(on Weblogic10gR3), when i keep clicking the netUI tree,
    i got a message in the jsp: PageFlow /Controller.jpf: Could not find exception handler method <b>handleException</b>.; but actually i have an exception handler for the SocketException called handleSocketException, and there is also an exception handler method called handleException. weird weird.. ;)
    In the Log, there was an exception thrown:
    com.cup.service.jpf.ServiceController - Service Management SocketError
    java.net.SocketException: Connection reset by peer: socket write error
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:525)
         at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:504)
         at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382)
         at weblogic.servlet.internal.CharsetChunkOutput.flush(CharsetChunkOutput.java:249)
         at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:469)
         at weblogic.servlet.internal.CharsetChunkOutput.write(CharsetChunkOutput.java:326)
         at weblogic.servlet.internal.CharsetChunkOutput.print(CharsetChunkOutput.java:233)
         at weblogic.servlet.internal.ChunkOutputWrapper.print(ChunkOutputWrapper.java:153)
         at weblogic.servlet.jsp.JspWriterImpl.print(JspWriterImpl.java:176)
         at org.apache.beehive.netui.tags.AbstractSimpleTag.write(AbstractSimpleTag.java:152)
         at org.apache.beehive.netui.tags.tree.Tree.doTag(Tree.java:936)
         at jsp_servlet._com._cup._soa._catweb._service._jpf.__index._jspService(__index.java:333)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.runPage(PageFlowPageFilter.java:385)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.doFilter(PageFlowPageFilter.java:284)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:503)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
         at org.apache.beehive.netui.pageflow.internal.DefaultForwardRedirectHandler.forward(DefaultForwardRedirectHandler.java:128)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlowRequestProcessor.java:1801)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processForwardConfig(PageFlowRequestProcessor.java:1674)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processInternal(PageFlowRequestProcessor.java:556)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.process(PageFlowRequestProcessor.java:853)
         at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.process(AutoRegisterActionServlet.java:631)
         at org.apache.beehive.netui.pageflow.PageFlowActionServlet.process(PageFlowActionServlet.java:158)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at com.cup.filter.LoginFilter.doFilter(LoginFilter.java:50)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    the class marked as bold is a filter in which i checked if the netUI tree is emplty, and the logic in the LoginFilter.java:50 is only : chain.doFilter(request, response);
    it seems that a socket exception is thrown with no reason, is it a NetUI issue????
    It's really urgent, could someone help me with that? ;)
    Thanks a lot!!!!!
    Edited by: Xu Wen on Sep 3, 2009 8:26 PM
    Edited by: Xu Wen on Sep 3, 2009 10:23 PM
    Edited by: Xu Wen on Sep 3, 2009 11:17 PM

    deepak,
    Sorry for replying your post so late as i am just back from my vacation. the entire thing is as follows:
    2009-09-16 14:30:45,546 ERROR [[ACTIVE] ExecuteThread: '21' for queue: 'weblogic.kernel.Default (self-tuning)'] com.cup.soa.catweb.service.jpf.ServiceController - Service Management SocketError
    java.net.SocketException: Software caused connection abort: socket write error
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:525)
         at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:504)
         at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382)
         at weblogic.servlet.internal.CharsetChunkOutput.flush(CharsetChunkOutput.java:249)
         at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:469)
         at weblogic.servlet.internal.CharsetChunkOutput.write(CharsetChunkOutput.java:326)
         at weblogic.servlet.internal.CharsetChunkOutput.print(CharsetChunkOutput.java:233)
         at weblogic.servlet.internal.ChunkOutputWrapper.print(ChunkOutputWrapper.java:153)
         at weblogic.servlet.jsp.JspWriterImpl.print(JspWriterImpl.java:176)
         at org.apache.beehive.netui.tags.AbstractSimpleTag.write(AbstractSimpleTag.java:152)
         at org.apache.beehive.netui.tags.tree.Tree.doTag(Tree.java:936)
         at jsp_servlet._com._cup._soa._catweb._service._jpf.__index._jspService(__index.java:338)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.runPage(PageFlowPageFilter.java:385)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.doFilter(PageFlowPageFilter.java:284)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:503)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
         at org.apache.beehive.netui.pageflow.internal.DefaultForwardRedirectHandler.forward(DefaultForwardRedirectHandler.java:128)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlowRequestProcessor.java:1801)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processForwardConfig(PageFlowRequestProcessor.java:1674)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processInternal(PageFlowRequestProcessor.java:556)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.process(PageFlowRequestProcessor.java:853)
         at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.process(AutoRegisterActionServlet.java:631)
         at org.apache.beehive.netui.pageflow.PageFlowActionServlet.process(PageFlowActionServlet.java:158)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at com.cup.soa.catweb.filter.LoginFilter.doFilter(LoginFilter.java:50)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    2009-09-16 14:30:48,000 ERROR [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] com.cup.soa.catweb.service.jpf.ServiceController - Service Management SocketError
    java.net.SocketException: Connection reset by peer: socket write error
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:525)
         at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:504)
         at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382)
         at weblogic.servlet.internal.CharsetChunkOutput.flush(CharsetChunkOutput.java:249)
         at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:469)
         at weblogic.servlet.internal.CharsetChunkOutput.write(CharsetChunkOutput.java:326)
         at weblogic.servlet.internal.CharsetChunkOutput.print(CharsetChunkOutput.java:233)
         at weblogic.servlet.internal.ChunkOutputWrapper.print(ChunkOutputWrapper.java:153)
         at weblogic.servlet.jsp.JspWriterImpl.print(JspWriterImpl.java:176)
         at org.apache.beehive.netui.tags.AbstractSimpleTag.write(AbstractSimpleTag.java:152)
         at org.apache.beehive.netui.tags.tree.Tree.doTag(Tree.java:936)
         at jsp_servlet._com._cup._soa._catweb._service._jpf.__index._jspService(__index.java:338)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.runPage(PageFlowPageFilter.java:385)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.doFilter(PageFlowPageFilter.java:284)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:503)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
         at org.apache.beehive.netui.pageflow.internal.DefaultForwardRedirectHandler.forward(DefaultForwardRedirectHandler.java:128)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlowRequestProcessor.java:1801)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processForwardConfig(PageFlowRequestProcessor.java:1674)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processInternal(PageFlowRequestProcessor.java:556)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.process(PageFlowRequestProcessor.java:853)
         at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.process(AutoRegisterActionServlet.java:631)
         at org.apache.beehive.netui.pageflow.PageFlowActionServlet.process(PageFlowActionServlet.java:158)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at com.cup.soa.catweb.filter.LoginFilter.doFilter(LoginFilter.java:50)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    2009-09-16 14:30:48,921 ERROR [[ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'] com.cup.soa.catweb.service.jpf.ServiceController - Service Management SocketError
    java.net.SocketException: Software caused connection abort: socket write error
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:525)
         at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:504)
         at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382)
         at weblogic.servlet.internal.CharsetChunkOutput.flush(CharsetChunkOutput.java:249)
         at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:469)
         at weblogic.servlet.internal.CharsetChunkOutput.write(CharsetChunkOutput.java:326)
         at weblogic.servlet.internal.CharsetChunkOutput.print(CharsetChunkOutput.java:233)
         at weblogic.servlet.internal.ChunkOutputWrapper.print(ChunkOutputWrapper.java:153)
         at weblogic.servlet.jsp.JspWriterImpl.print(JspWriterImpl.java:176)
         at org.apache.beehive.netui.tags.AbstractSimpleTag.write(AbstractSimpleTag.java:152)
         at org.apache.beehive.netui.tags.tree.Tree.doTag(Tree.java:936)
         at jsp_servlet._com._cup._soa._catweb._service._jpf.__index._jspService(__index.java:338)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.runPage(PageFlowPageFilter.java:385)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.doFilter(PageFlowPageFilter.java:284)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:503)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
         at org.apache.beehive.netui.pageflow.internal.DefaultForwardRedirectHandler.forward(DefaultForwardRedirectHandler.java:128)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlowRequestProcessor.java:1801)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processForwardConfig(PageFlowRequestProcessor.java:1674)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processInternal(PageFlowRequestProcessor.java:556)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.process(PageFlowRequestProcessor.java:853)
         at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.process(AutoRegisterActionServlet.java:631)
         at org.apache.beehive.netui.pageflow.PageFlowActionServlet.process(PageFlowActionServlet.java:158)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at com.cup.soa.catweb.filter.LoginFilter.doFilter(LoginFilter.java:50)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    2009-09-16 14:30:49,062 ERROR [[ACTIVE] ExecuteThread: '19' for queue: 'weblogic.kernel.Default (self-tuning)'] com.cup.soa.catweb.service.jpf.ServiceController - Service Management SocketError
    java.net.SocketException: Connection reset by peer: socket write error
         at java.net.SocketOutputStream.socketWrite0(Native Method)
         at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
         at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
         at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:525)
         at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:504)
         at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382)
         at weblogic.servlet.internal.CharsetChunkOutput.flush(CharsetChunkOutput.java:249)
         at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:469)
         at weblogic.servlet.internal.CharsetChunkOutput.write(CharsetChunkOutput.java:326)
         at weblogic.servlet.internal.CharsetChunkOutput.print(CharsetChunkOutput.java:233)
         at weblogic.servlet.internal.ChunkOutputWrapper.print(ChunkOutputWrapper.java:153)
         at weblogic.servlet.jsp.JspWriterImpl.print(JspWriterImpl.java:176)
         at org.apache.beehive.netui.tags.AbstractSimpleTag.write(AbstractSimpleTag.java:152)
         at org.apache.beehive.netui.tags.tree.Tree.doTag(Tree.java:936)
         at jsp_servlet._com._cup._soa._catweb._service._jpf.__index._jspService(__index.java:338)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.runPage(PageFlowPageFilter.java:385)
         at org.apache.beehive.netui.pageflow.PageFlowPageFilter.doFilter(PageFlowPageFilter.java:284)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:503)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
         at org.apache.beehive.netui.pageflow.internal.DefaultForwardRedirectHandler.forward(DefaultForwardRedirectHandler.java:128)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.doForward(PageFlowRequestProcessor.java:1801)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processForwardConfig(PageFlowRequestProcessor.java:1674)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processInternal(PageFlowRequestProcessor.java:556)
         at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.process(PageFlowRequestProcessor.java:853)
         at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.process(AutoRegisterActionServlet.java:631)
         at org.apache.beehive.netui.pageflow.PageFlowActionServlet.process(PageFlowActionServlet.java:158)
         at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at com.cup.soa.catweb.filter.LoginFilter.doFilter(LoginFilter.java:50)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Still the message saying handleException is not found . (Weird)
    Any idea what's wrong??
    Thanks a lot
    Regards,
    Wen
    Edited by: Xu Wen on Sep 21, 2009 2:00 AM

  • Resizing Columns in Tree Table

    hi all!
    Iam using TreeTable's in my application. It is already developed by somebody. Now what is my problem is when I try to resize the column the subsequent columns are not resizing.
    Can any body help me out to fix this issue
    Thanks in Advance

    I think you got this code from site na?
    I have already seen this code in the net. But I didn't found mistake in our code. What actually is it was developed by somebody.
    If you don't mind I will send that code can you please observe it for the mistake.
    Here is my code:
    Here all the things beginning:
    private void configureForm()
    setBorder(editor.buildBorder(presenter
    .doGetProperty("vmtp.info.testCaseSelector.title")));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    tree = new TestCaseTree(presenter, testCaseIn, testCaseOut);
    ActionTreeTablePanel actionTreeTablePanel = new ActionTreeTablePanel(tree, presenter);
    this.add(actionTreeTablePanel);
    Here is the TestCaseTree.java file:
    public class TestCaseTree extends ActionTreeTable implements TreeExpansionListener
    public TestCaseTree(Presenter presenter, TestCaseTO testCaseIn, TestCaseTO testCaseOut)
    super(presenter, testCaseOut, testCaseOut.getActions(), new TestCaseTreeToolbar(presenter));
    addTreeExpansionListener(this);
    ActionBaseTO.enumerateActions(testCaseOut.getActions());
    * This statement causes tooltip to display for child nodes
    setToolTipText(testCaseIn.getName());
    /* (non-Javadoc)
    * @see javax.swing.JTree#isPathEditable()
    @Override
    public boolean isPathEditable(TreePath path)
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent().getParent();
    * Commenting out below lines to enable editing of parameter values for
    * action groups in a test case
    //if(parent != null && parent.getUserObject() instanceof ActionTreeTableNode)
    //if(((ActionTreeTableNode)parent.getUserObject()).getAction().isGroup())
    // return false;
    return super.isPathEditable(path);
    public void setVecTreeStateBookmark(Vector treeState) {
         BookmarkTO bookmark = VmtpSession.getVmtpSession().getBookmark();
         BookmarkItemTO bookmarkItem = bookmark.getLastMarkedItem();
         if (bookmarkItem != null && parentObject != null
         && bookmarkItem.getObjectId() == ((TestCaseTO)parentObject).getId()
         && bookmarkItem.getObjectType() == BookmarkItemType.TESTCASE) {
         bookmarkItem.setTreeState(treeState);
    public void updateVecTreeStateBookmark() {
              BookmarkTO bookmark = VmtpSession.getVmtpSession().getBookmark();
              BookmarkItemTO bookmarkItem = bookmark.getLastMarkedItem();
              Vector rowVec = currentExpandedPath();
              if (bookmarkItem != null
                        && parentObject != null
                        && bookmarkItem.getObjectId() == ((TestCaseTO) parentObject)
                                  .getId()
                        && bookmarkItem.getObjectType() == BookmarkItemType.TESTCASE) {
                   bookmarkItem.setTreeState(rowVec);
    private Vector currentExpandedPath() {
              Vector rowVec = new Vector();
              for (int i = 0; i < getRowCount(); i++) {
                   String expandedPath = null;
                   String currPathExpanded = getPathExpanded(i);
                   if (!currPathExpanded.equals("")) {
                        expandedPath = i + getPathExpanded(i);
                        rowVec.add(expandedPath);
              return rowVec;
    private String getPathExpanded(int row) {
         String str = "";
         TreePath path = getPathForRow(row);
         int noofrows = this.getRowCount();
         for(int i = row; i < noofrows; i++) {
              TreePath currPath = this.getPathForRow(i);
              if(i==row || currPath.isDescendant(path)) {
                   if(this.isExpanded(currPath)) {
                        str = str + "," + (i - row);
         return str;
    public Vector getVecTreeStateBookmark() {
         BookmarkTO bookmark = VmtpSession.getVmtpSession().getBookmark();
         BookmarkItemTO bookmarkItem = bookmark.getLastMarkedItem();
         if (bookmarkItem != null && parentObject != null
         && bookmarkItem.getObjectId() == ((TestCaseTO)parentObject).getId()
         && bookmarkItem.getObjectType() == BookmarkItemType.TESTCASE)
         return bookmarkItem.getTreeState();
         return null;
         public void treeCollapsed(TreeExpansionEvent event) {
              updateVecTreeStateBookmark();
              // TODO Auto-generated method stub
         public void treeExpanded(TreeExpansionEvent event) {
              updateVecTreeStateBookmark();
              // TODO Auto-generated method stub
    Here is ActionTreeTable.java
    public abstract class ActionTreeTable extends JTree
    protected Presenter presenter;
    protected DefaultMutableTreeNode top;
    private ActionTreeTableModel treeModel;
    protected List<ActionTO> actions;
    private ParameterTO selectedParameter;
    private JScrollPane scrollPane;
    protected ActionTreeTableToolbar toolbar;
    protected AbstractToolbarTable selectedTable;
    //A jtableheader to be propogated to the parametertablemodel
    protected JTableHeader                    header;
    * The parent object to actions, such as test case, action group etc.
    protected AbstractTO parentObject;
    private Collection<ParameterTable> tables = new ArrayList<ParameterTable>();
    private int tableWidth = 100;
    public ActionTreeTable(Presenter presenter, AbstractTO parentObject,
              Collection<ActionTO> actions, ActionTreeTableToolbar toolbar)
    super();
    this.parentObject = parentObject;
    this.actions = (List<ActionTO>)actions;
    this.toolbar = toolbar;
    this.presenter = presenter;
    toolbar.setTree(this);
    configureTreeTable();
    * bad programming but needs to be done to adhere to the existing design of the table
    * header and the tree tables
    * @param tableHeader
    public void setHeader(JTableHeader tableHeader) {
         this.header = tableHeader;
         if(header != null && tables.size() >= 1) {
              Object[] currTables = tables.toArray();
              for(int i = 0; i < currTables.length; i++) {
                   ParameterTableLite currLiteTable = (ParameterTableLite)currTables;
                   ParameterTableModel model = currLiteTable.getParameterModel();
                   model.setTableHeader(tableHeader);
         // adding a mouse listener to the header that updates the tree when the
              // mouse is clicked on the header and all the table models are sorted
              // according to the desired column
              tableHeader.addMouseListener(new MouseListener() {
                   public void mouseClicked(MouseEvent e) {
                        repaint();
                   public void mouseEntered(MouseEvent e) {
                        // ignored
                   public void mouseExited(MouseEvent e) {
                        // ignored
                   public void mousePressed(MouseEvent e) {
                        // ignored
                   public void mouseReleased(MouseEvent e) {
                        // ignored
    public JTableHeader getHeader() {
         return header;
    private void configureTreeTable()
    this.setRootVisible(false);
    this.setShowsRootHandles(true);
    this.setMaximumSize(new Dimension(2000, 2000));
    buildTree();
    //expandTreePerBookmark();
    public synchronized boolean buildTree()
    boolean outcome = false;
    addMouseListener(new ActionTreeTableMouseListener(this));
    try {
    top = new DefaultMutableTreeNode(null);
    treeModel = new ActionTreeTableModel(top, actions);
    setModel(treeModel);
    addActionsToRoot(actions);
    if (this.getRowHeight() <= 0)
    // Temporary change to non-zero height
    this.setRowHeight(1);
    this.setRowHeight(0);
    //ActionTreeTableCellRenderer renderer=new ActionTreeTableCellRenderer();
    //System.out.println(renderer.getComponent(1));
    this.setCellRenderer(new ActionTreeTableCellRenderer());
    this.setCellEditor(new ActionTreeTableCellEditor(this));
    this.setEditable(true);
    this.validateTree();
    outcome = true;
    } catch (Exception e) {
    // log.log(Level.SEVERE, "Can't load data", e);
    } finally {
    return outcome;
    * Set the expanded nodes in the tree in the bookmark
    * @param treeExpanded true if tree is expanded, false if tree is collapsed
    public abstract void setVecTreeStateBookmark(Vector treeState);
    * Get tree's previous state from bookmark
    * @return true if tree was previously expanded, false if collpased
    public abstract Vector getVecTreeStateBookmark();
    public void addActionsToRoot(Collection<ActionTO> newActions)
    this.addActionsToTree(newActions, top, false);
    public void addActionsToTree(Collection<ActionTO> newActions, DefaultMutableTreeNode parent, boolean groupActions)
    Iterator iterator = newActions.iterator();
    ActionTO actionTO;
    DefaultMutableTreeNode node;
    ParameterTable parameterTable = null;
    while (iterator.hasNext())
    actionTO = (ActionTO)iterator.next();
    node = new DefaultMutableTreeNode(new ActionTreeTableNode(actionTO));
    if(actionTO.isGroup())
    this.addActionsToTree(actionTO.getActionGroup().getActions(), node, true);
    else
    JPanel tablePanel = new JPanel();
    ParameterTableModel model =
    new ParameterTableModel(actionTO, actionTO,
              ParameterTableModel.MODE_IMPLEMENTATION, presenter);
    if(groupActions)
    model.setGroupAction(true);
    parameterTable = new ParameterTableLite(tablePanel, presenter, model, this);
    parameterTable.setToolbar(toolbar);
    tables.add(parameterTable);
    parameterTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    parameterTable.setAutoscrolls(true);
    node.add(new DefaultMutableTreeNode(parameterTable));
    * When creating ActionGroups this will be executed when we are adding new
    * actions to the tree.
    if(newActions != actions && parent == top)
    actions.add(actionTO);
    * Passing -1 as index means that the underlying collection of ActionTOs
    * won't be affected. This has already been taken care of above.
    // treeModel.insertNodeInto(node, parent, parent.getChildCount());
    treeModel.insertNodeInto(node, parent, -1);
    treeModel.reload();
    public void removeActionFromTree(MutableTreeNode node)
    treeModel.removeNodeFromParent(node);
    public void moveActionUp(TreePath path)
    DefaultMutableTreeNode nodeToMove = (DefaultMutableTreeNode)path.getLastPathComponent();
    this.moveAction(nodeToMove, -1);
    public void moveActionDown(TreePath path)
    DefaultMutableTreeNode nodeToMove = (DefaultMutableTreeNode)path.getLastPathComponent();
    this.moveAction(nodeToMove, 1);
    public void moveAction(DefaultMutableTreeNode nodeToMove, int offset)
    treeModel.moveAction(nodeToMove, offset);
    setSelectionRow(treeModel.getIndexOfChild(top, nodeToMove));
    * @param selectedParameter The selectedParameter to set.
    public void setSelectedParameter(ParameterTO selectedParameter)
    this.selectedParameter = selectedParameter;
    public AbstractToolbarTable getSelectedTable()
    TreePath path = this.getSelectionPath();
    if(path != null)
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    if(node.getUserObject() instanceof JTable)
    return (AbstractToolbarTable)node.getUserObject();
    return null;
    public ParameterTO getSelectedParameter()
    TreePath path = this.getSelectionPath();
    if(path != null)
    DefaultMutableTreeNode node =
    (DefaultMutableTreeNode)path.getLastPathComponent();
    if(node.getUserObject() instanceof AbstractToolbarTable)
    AbstractToolbarTable table =
    (AbstractToolbarTable)node.getUserObject();
    if(table.getSelectedRow() != -1)
    return (ParameterTO)table.getTableModel().getRowData(table.getSelectedRow());
    return null;
    public void collapseTree()
    int row = getRowCount() - 1;
    while (row >= 0)
    collapseRow(row);
    row--;
    public void expandTree()
    int row = 0;
    while (row < getRowCount())
    expandRow(row);
    row++;
    * @return Returns the scrollPane.
    public JScrollPane getScrollPane()
    return scrollPane;
    * @param scrollPane The scrollPane to set.
    public void setScrollPane(JScrollPane scrollPane)
    this.scrollPane = scrollPane;
    public void setEnabled(boolean isEnabled)
    // super.setEnabled(isEnabled);
    setEditable(isEnabled);
    ParameterTable tmpTable;
    for(Iterator i = tables.iterator() ; i.hasNext() ;)
    tmpTable = (ParameterTable)i.next();
    * Commented out below lines to enable editing of parameter values
    * for action groups in a test case
    //if(tmpTable.isGroupAction())
    // tmpTable.setEnabled(false);
    //else
    // tmpTable.setEnabled(isEnabled);
    tmpTable.setEnabled(isEnabled);
    toolbar.setToolbarEnabled(isEnabled);
    public void setBounds(int x, int y, int w, int h)
    clearSelection();
    super.setBounds(x, y, w, h);
    private int calculateTableWidth(JTable table)
    JViewport viewPort = getScrollPane().getViewport();
    int vpW = viewPort.getWidth();
    int tableX = table.getLocation().x;
    return getScrollPane().getWidth() - 80;
    * @return Returns the toolbar.
    public AbstractTableToolbar getToolbar()
    return toolbar;
    * @param selectedTable The selectedTable to set.
    public void setSelectedTable(AbstractToolbarTable selectedTable)
    this.selectedTable = selectedTable;
    /* (non-Javadoc)
    * @see javax.swing.JTree#fireValueChanged(javax.swing.event.TreeSelectionEvent)
    @Override
    protected void fireValueChanged(TreeSelectionEvent event)
    if(getSelectionPath() != null && ((DefaultMutableTreeNode)getSelectionPath().
    getLastPathComponent()).getUserObject()
    instanceof ActionTreeNode && isEditable())
    toolbar.setNodeToolsEnabled(true);
    else
    toolbar.setNodeToolsEnabled(false);
    if(selectedTable != null)
    this.selectedTable.clearSelection();
    super.fireValueChanged(event);
    /* (non-Javadoc)
    * @see javax.swing.JTree#isPathEditable()
    @Override
    public boolean isPathEditable(TreePath path)
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    if(node.getUserObject() instanceof ActionTreeNode)
    return false;
    return super.isPathEditable(path);
    And finally here is ActionTreeTablePanel.java
    public class ActionTreeTablePanel extends JPanel
    * Width and height is set based on the BoxLayout used by
    * the parent container. This might need to be modified
    * if the parent container layout is changed.
    private final int HEADER_WIDTH = 3000;
    private final int HEADER_HEIGHT = 18;
    private final int FIRST_COLUMN_WIDTH = 41;
    private final int LAST_COLUMN_WIDTH = 60;
    private ActionTreeTable tree;
    private JTable defaultTable = null;
    private Presenter     presenter;
    //a variable to give the reference of the tableheader of the main scrollPane to the
    //parametertablemodel to enable sorting
    //the parametertablemodel implements the view to model technique and makes
    //the necessary changes to the model and captures events for the tableheader
    private JTableHeader header = null;
    * Constructs an <code>ActionTreeTable</code> as a ready component
    * to be used in an application.
    * @param tree
    public ActionTreeTablePanel(ActionTreeTable tree, Presenter presenter)
    this.tree = tree;
    this.presenter = presenter;
    this.buildPanel();
    * Called from the constructor to build the component.
    private void buildPanel()
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setVerticalScrollBarPolicy(
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    tree.setScrollPane(scrollPane);
    this.add(getDefaultTableInScrollPane());
    //header needs to be the same as the
    tree.setHeader(header);
    this.add(scrollPane);
    if(tree.getToolbar() != null)
    this.add(tree.getToolbar());
    * Helper method to build the header for the <code>ActionTreeTable</code>
    * @return
    private JScrollPane getDefaultTableInScrollPane()
    if(defaultTable == null)
    defaultTable = new JTable();
    final JTableHeader tableHeader = defaultTable.getTableHeader();
    TableColumn column = new TableColumn();
    defaultTable.setMaximumSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    defaultTable.setPreferredSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    defaultTable.setSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    // defaultTable.setAutoResizeMode(4);
    column.setHeaderValue(" ");
    column.setWidth(FIRST_COLUMN_WIDTH);
    column.setMaxWidth(FIRST_COLUMN_WIDTH);
    tableHeader.setAlignmentX(FIRST_COLUMN_WIDTH);
    // tableHeader.set;
    // tableHeader.getColumnModel().addColumn(column);
    for(int i=0 ; i < ParameterTableModel.columnNamesImpl.length ; i++)
    column = new TableColumn(i);
    column.setHeaderValue(presenter.doGetProperty(ParameterTableModel.columnNamesImpl[i]));
    tableHeader.getColumnModel().addColumn(column);
    column = new TableColumn();
    column.setHeaderValue(" ");
    column.setWidth(LAST_COLUMN_WIDTH);
    column.setMaxWidth(LAST_COLUMN_WIDTH);
    // tableHeader.getColumnModel().addColumn(column);
    tableHeader.setResizingAllowed(true);
    tableHeader.setReorderingAllowed(false);
    header = defaultTable.getTableHeader();
    //doing the same changes as before and adjusted the size of the columns manually
    //and the size of the columns do not change by listening to user events.
    TableColumn typeColumn = defaultTable.getColumnModel().getColumn(
    ParameterTableModel.TYPE_COL_ID ); // Empty col
    typeColumn.setWidth(ParameterTable.WIDTH_TYPE_COLUMN );
    typeColumn.setMaxWidth(ParameterTable.WIDTH_TYPE_COLUMN);
    TableColumn requiredColumn = defaultTable.getColumnModel().getColumn(
    ParameterTableModel.REQUIRED_COL_ID); // Empty col
    requiredColumn.setWidth(ParameterTable.WIDTH_REQURIED_COLUMN + FIRST_COLUMN_WIDTH);
    requiredColumn.setPreferredWidth(ParameterTable.WIDTH_REQURIED_COLUMN + FIRST_COLUMN_WIDTH);
    requiredColumn.setMaxWidth(ParameterTable.WIDTH_REQURIED_COLUMN + FIRST_COLUMN_WIDTH);
    TableColumn valueColumn = defaultTable.getColumnModel().getColumn(
    ParameterTableModel.VALUE_COL_ID); // Empty col
    valueColumn.setWidth(ParameterTable.WIDTH_VALUE_COLUMN + LAST_COLUMN_WIDTH);
    valueColumn.setPreferredWidth(ParameterTable.WIDTH_VALUE_COLUMN + LAST_COLUMN_WIDTH);
    valueColumn.setMaxWidth(ParameterTable.WIDTH_VALUE_COLUMN + LAST_COLUMN_WIDTH);
    JScrollPane scrollPane = new JScrollPane(defaultTable);
    scrollPane.setMaximumSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    scrollPane.setPreferredSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    scrollPane.setSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    return scrollPane;
    Please guys help me out. My boss is angry upon me..

  • Error in t:tree component of tomahawk

    I am using tree component of tomahawk like this in my xhtml file
    <t:tree id="tree" value="#{treeBean.tree}"
    styleClass="tree"
    nodeClass="treenode"
    selectedNodeClass="treenodeSelected"
    expandRoot="true">
    </t:tree>
    and this is my class file,
    public class TreeBean
    private DefaultTreeModel tree;
    public DefaultTreeModel getTree() {
    return tree;
    public void setTree(DefaultTreeModel tree) {
    this.tree = tree;
    public TreeBean()
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("XY");
    DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
    root.insert(a);
    DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
    root.insert(b);
    DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");
    root.insert(c);
    DefaultMutableTreeNode node = new DefaultMutableTreeNode("a1");
    a.insert(node);
    node = new DefaultMutableTreeNode("a2 ");
    a.insert(node);
    node = new DefaultMutableTreeNode("b ");
    b.insert(node);
    a = node;
    node = new DefaultMutableTreeNode("x1");
    a.insert(node);
    node = new DefaultMutableTreeNode("x2");
    a.insert(node);
    tree = new DefaultTreeModel(root);
    but when i run my xhtml file, i am getting error like this,
    java.lang.NullPointerException
         at org.apache.myfaces.custom.tree.HtmlTree.addToModelListeners(HtmlTree.java:806)
    at org.apache.myfaces.custom.tree.HtmlTree.encodeBegin(HtmlTree.java:683)
    at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232)
         at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
         at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
         at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
         at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
         at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:245)
         at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
         at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
         at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
         at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:217)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:197)
         at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
         at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
         at incture.view.SecurityFilter.doFilter(SecurityFilter.java:62)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
         at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
         at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:217)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:197)
         at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
         at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Thread.java:595)
    How to solve this,
    Regars,
    Vinutha.

    Hi i have the same problem, Did you found a solution ?

  • Editing in Tree....

    Hi group,
    In my tree I am setting in setCellRenderer method like
    mytree.setCellRenderer(new CellRend());
    In CellRend class:which extends DefaultTreeCellRenderer.
    in that getTreeCellRendererComponent()... I write like..
    public java.awt.Component getTreeCellRendererComponent(
         javax.swing.JTree tree,
         Object value,
         boolean sel,
         boolean expanded,
         boolean leaf,
         int w,
         boolean hasFocus) {
         setOpenIcon(new ImageIcon("open.gif"));
         setClosedIcon(new ImageIcon("closed.jpg"));
         java.awt.Component compo = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, w, hasFocus);
         javax.swing.tree.DefaultMutableTreeNode node = (javax.swing.tree.DefaultMutableTreeNode)value;
         if(node.toString().equalsIgnoreCase("House"))
              tree.setEditable(false);
         else
              tree.setEditable(true);
         return compo;
    in my tree I have "House" node out of 10 nodes.
    I don't want to edit that particular "House" node.
    But as per my code it is editing why?
    Is any possible solution not to edit that "House" node.?
    Shalinipriya.

    if you call tree.setEditable(true) (or false) this changes the editing option for the entire tree, not just the current node. And the tree cell renderer gets called for all the nodes... So here's what is happening in your code:
    Let us assume that node 7 is your "House" node...
    The tree starts to render the nodes... it calls getTreeCellRendererComponent() for nodes 1 to 6, and each time, the expression (node.toString().equalsIgnoreCase("House")) is false, so it does: tree.setEditable(true). OK - now it gets to node 7, and (node.toString().equalsIgnoreCase("House")) is now true, so it does tree.setEditable(false) - making the entire tree not editable. Finally, it renders nodes 8, 9 & 10, where (node.toString().equalsIgnoreCase("House")) is false again, so it does: tree.setEditable(true), so when it has finished rendering, the entire tree is editable.
    That's why it doesn't work. Now, I don't know if you can directlly make only one single node editable or not editable (unless someone else knows different??) One workaround would be to add a listener, and if the user tries to edit your House node, pop up a message telling them not to, or just silently change its value back to House after they have finished (That'll frustrate the hell out of 'em ;-)

  • How to remove folder and leaf icons from a tree

    Hi,
    I know how to remove when we have a mx component i.e.,
    <mx:Tree folderOpenIcon={null} ...../> similarly for
    closed and default leaf icon.
    But how do i achieve this from an action script like say i
    have,
    var tree:Tree = new Tree();
    tree.setFolderOpenIcon(null); ///is there something like this
    or any other alternative.
    Please advice.
    Thanks,
    Lucky

    the folderOpenIcon is a style so you have to set it with the
    setStyle method
    try:
    tree.setStyle("folderOpenIcon",null);

Maybe you are looking for