Making tree nodes appear "inactive"

Hi,
I have a tree control which displays a hierarchy. The
dataprovider is an ArrayCollection. I want to display certain nodes
in grey to indicate that that branch of the hierarchy is inactive.
How can this be achieved?

ItemRenderers are not simple. I advise starting with an
existing one and modifying it to meet your needs.
There is an example of a custom TreeItemRenderer on
www.cflex.net. It is simple enough to be understandable, but
complex enough to be helpful. There are certainly more examples
available. Google.
Tracy

Similar Messages

  • 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);
    }

  • How to cut, copy and paste a tree node in JTree?????

    Hi, Java GUI guru. Thank you for your help in advance.
    I am working on a File Explorer project with JTree. There are cut, copy and paste item menus in my menu bar. I need three EventAction methods or classes to implements the three tasks. I tried to use Clipboard to copy and paste tree node. But I can not copy any tree node from my tree.
    Are there any body has sample source code about cut, copy, and paste for tree? If possible, would you mind send me your sample source code to [email protected]
    I would appreciate you very very much for your help!!!!
    X.G.

    Hi, Paul Clapham:
    Thank you for your quick answer.
    I store the node in a DefaultMutableTreeNode variable, and assign it to another DefaultMutableTreeNode variable. I set up two classes (CopyNode and PasteNode). Here they are as follows:
    //CopyNode class
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class CopyNode implements ActionListener{
    private TreeList jtree;
    String treeNodeName;
    TreePath currentSelection;
    DefaultMutableTreeNode currentNode;
    public CopyNode(TreeList t){
    jtree = t;
    public void actionPerformed(ActionEvent e){
    currentSelection = jtree.tree.getSelectionPath();
    if(currentSelection != null){
    currentNode = (DefaultMutableTreeNode)(currentSelection.getLastPathComponent());
    treeNodeName = currentNode.toString();
    //PasteNode class
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class PasteNode extends DefaultMutableTreeNode{
    private TreeList jtree;
    CopyNode copyNode;
    public PasteNode(TreeList t){
    jtree = t;
    copyNode = new CopyNode(t);
    public DefaultMutableTreeNode addObject(Object child){
    DefaultMutableTreeNode parentNode = null;
    TreePath parentPath = jtree.tree.getSelectionPath();
    if(parentPath == null){
    parentNode = jtree.root;
    else{
    parentNode = (DefaultMutableTreeNode)parentPath.getLastPathComponent();
    return addObject(parentNode, child, true);
    public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent, Object child, boolean shouldBeVisible){
    DefaultMutableTreeNode childNode = copyNode.currentNode;
    if(parent == null){
    parent = jtree.root;
    jtree.treemodel.insertNodeInto(childNode, parent, parent.getChildCount());
    if(shouldBeVisible){
    jtree.tree.scrollPathToVisible(new TreePath(childNode.getPath()));
    return childNode;
    I used these two classes objects in "actionPerformed(ActionEvent e)" methods in my tree:
    //invoke copyNode
    copyItem = new JMenuItem("Copy");
    copyItem.addActionListener(copyNode);
    //invoke pasteNode
    pasteItem = new JMenuItem("Paste");
    pasteItem.addActionListener(
    new ActionListener(){
    public void actionPerformed(ActionEvent e){
    pasteName.addObject(copyName.treeNodeName);
    When I run the drive code, making a copy some node from my tree list, I got bunch of error messages.
    Can you figour out what is wrong in my two classes? If you have sample code, would you mind mail me for reference.
    Thank you very much in advance.
    X.G.

  • Display tree node data in bold characters

    Hi,
    I have a requirement where I need to display tree nodes data in bold characters. If I click on a particular tree node, next time it should appear in normal font only which means that some task had done using that tree node. Is my question clear??
    Plz help me....
    thanks,
    ravindra.

    Hi Ravindra,
    I think it is possible, i have not done it but let me explain how we can do it.
    In <htmlb:treeNode> tag there is an attribute 'text' in
    which we specify title of that treeNode.
    Now you define a page attribute 'treeNodeTitle' type
    edpline and in onCreate assign it value <html><b>MyTreeNode</b></html>
    When you click on this node then you do event handling
    in onInputProcessing, there assign only 'MyTreeNode' to
    treeNodeTitle.
    sample code may look like this...
    <htmlb:treeNode
      id = 'treeNode1'
      text = '<%=treeNodeTitle %>' >
    </htmlb:treeNode>
    Page Attribute
    treeNodeTitle type edpline
    in onCreate
    treeNodeTitle = '<html><b>MyTreeNode</b></html>'
    in onInputProcessing
    in event-handling code for that treeNode write
    treeNodeTitle = 'MyTreeNode'
    I hope this will work.
    Regards,
    Narinder Hartala

  • Setting Dialog, Tree Node and Menu Font in JDeveloper 11.1.1.4/11.1.1.5

    Hi,
    I'm near sighted and thus dependent on being able to choose larger fonts. For the code editor, this poses no problem. For the widgets in the views surrounding the editor (containing tree nodes) and dialogs (with the Preferences dialog being one example), the font is very small at high screen resolutions (I don't want to resort to a lower resolution since I would like the fonts to appear as detailed as possible).
    Is there any way to override the menu, tree node, and dialog font via command line switches and/or property/config files during JDeveloper startup in a platform independent way?
    If it can't be done platform independently, what are the necessary steps on Linux (probably for the GTK lib) and Windows?
    Thanks in advance!
    Kind regards,
    Holger

    I previously developed under full screen option and my PC resolution was 1600x1200. But when the application was ran on other screens it was displaying with some page contents being cut out. It was due to other machines running on lower resoultion. I will need now redesign the pages to run on user defined lower resolution of 1280x1024. How do I setup Jdeveloper design tab to show for 1280x1024.
    Thanks
    Edited by: user5108636 on Feb 14, 2011 5:23 PM

  • Tree and Tree Node Components - Threadinar7

    Hi All,
    This is the seventh in the "Threadinar" series , please see Threadinar6 at
    http://forum.sun.com/jive/thread.jspa?threadID=100601 for details
    In this Threadinar we will focus on the
    "Tree" and "Tree Node" Components
    Let us begin our discussion with the Tree Component.
    Tree Component
    You can drag the Tree component from the Palette's Basic category to the Visual Designer to create a hierarchical tree structure with nodes that can be expanded and collapsed, like the nodes in the Outline window. When the user clicks a node, the row will be highlighted. A tree is often used as a navigation mechanism.
    A tree contains Tree Node components, which act like hyperlinks. You can use a Tree Node to navigate to another page by setting its url property. You can also use a Tree Node to submit the current page. If the the Tree Node's action property is bound to an action event handler, selecting the node automatically submits the page. If the Tree Node's actionListener property is bound to an action listener, opening or closing the node automatically submits the page. You set Tree Node properties in the Tree Node Component Properties window.
    * If you use this component to navigate between pages of a portlet, do not use the url property to link to a page. Instead, use the Navigation editor to set up your links to pages.
    * Events related to tree node selection do not work correctly in portlets because the component uses cookies to pass the selected node id back and forth, and cookies are not correctly handled by the portlet container. You cannot handle tree node selection events in portlet projects.
    Initially when you drop a tree on a page, it has one root node labeled Tree and one subnode labeled Tree Node 1. You can add more nodes by dragging them to the tree and dropping them either on the root node to create top level nodes or on existing nodes to create subnodes of those nodes. You can also right-click the Tree or any Tree Node and choose Add Tree Node to add a subnode to the node.
    Additionally, you can work with the component in the Outline window, where the component and its child components are available as nodes. You can move a node from level to level easily in the Outline window, so you might want to work there if you are rearranging nodes. You can also add and delete tree nodes in the Outline window, just as in the Visual Designer.
    The Tree component has properties that, among other things, enable you change the root node's displayed text, change the appearance of the text, specify if expanding or collapsing a node requires a trip to the server, and specify whether node selection should automatically open or close the tree. To set the Tree's properties, select the Tree component in your page and use the Tree Component Properties window.
    The following Tutorial ("Using Tree Component") is very useful to learn using Tree components
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/sitemaptree.html
    See Also the Technical Article - "Working with the Tree Component and Tree Node Actions"
    http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/tree_component.html
    Tree Node Component
    You can drag the Tree Node component from the Palette's Basic category to a Tree component or another tree node in the Visual Designer to create a node in a hierarchical tree structure, similar to the tree you see in the Outline window.
    The tree node is created as a subnode of the node on which you drop it. If you drop the node on the tree component itself, a new node is created as a child of the root node. You can see the hierarchical structure clearly in the Outline window, where you can also easily move nodes around and reparent them.
    You can also add a tree node either to a Tree component or to a Tree Node component by right-clicking the component and choosing Add Tree Node.
    A Tree Node component by default is a container for an image and can be used to navigate to another page, submit the current page, or simply open or close the node if the node has child nodes.
    * If you select the Tree Node component's node Tree Node icon in the Outline window, you can edit its properties in the Tree Node Properties window. You can set things like whether or not the Tree Node is expanded by default, the tooltip for the Tree Node, the label for the tree node, and the Tree Node's identifier in your web application.
    * You can use a Tree Node to navigate to another page by setting its url property. You can also use a Tree Node to submit the current page. If the the Tree Node's action property is bound to an action event handler, selecting the node automatically submits the page. If the Tree Node's actionListener property is bound to an action listener, opening or closing the node automatically submits the page.
    - Note: If you use this component to navigate between pages of a portlet, do not use the url property to link to a page. Instead, use the Navigation editor to set up your links to pages. In addition, events related to tree node selection do not work correctly in portlets because the component uses cookies to pass the selected node id back and forth, and cookies are not correctly handled by the portlet container. You cannot handle tree node selection events in portlet projects.
    * If you select the image in the Tree Node, you can see that its icon property is set to TREE_DOCUMENT. If you right-click the image on the page and choose Set Image, you can either change the icon to another one or choose your own image in the Image Customizer dialog box. For more information on working with an image in a tree node, see Image component.
    - Note: The image used in a tree node works best if it is 16x16 or smaller. Larger images can work, but might appear overlapped in the Visual Designer. You can right-click the component and choose Preview in Browser feature to check the appearance of the images.
    Please share your comments, experiences, additional information, questions, feedback, etc. on these components.
    ------------------------------------------------------------------------------- --------------------

    One challenge I had experience was to make the tree
    always expanded on all pages (I placed my tree menu
    in a page fragment so I can just import it in my
    pages).Did you solve this problem. It would be interesting to know what you did.
    To expand a node you call setExpanded on the node. Here is some code from a tutorial that a coworker of mine is working on.
    In the prerender method:
           Integer expandedPersonId = getRequestBean1().getPersonId();
             // If expandedPersonId is null, then we are not coming back
            // from the Trip page. In that case we do not want any trip
            // nodes to be pre-selected (highlighted) due to browser cookies.
            if (expandedPersonId==null) {
                try {
                    HttpServletRequest req =(HttpServletRequest)
                    getExternalContext().getRequest();
                    Cookie[] cookies = req.getCookies();
                    //Check if cookies are set
                    if (cookies != null) {
                        for (int loop =0; loop < cookies.length; loop++) {
                            if (cookies[loop].getName().equals
                                    ("form1:displayTree-hi")) {
                                cookies[loop].setMaxAge(0);
                                HttpServletResponse response =(HttpServletResponse)
                                getExternalContext().getResponse();
                                response.addCookie(cookies[loop]);
                } catch (Exception e) {
                    error("Failure trying to clear highlighting of selected node:" +
                            e.getMessage());
            }                  ... (in a loop for tree nodes)...
                      personNode.setExpanded(newPersonId.equals
                                    (expandedPersonId));In the action method for the nodes:
           // Get the client id of the currently selected tree node
            String clientId = displayTree.getCookieSelectedTreeNode();
            // Extract component id from the client id
            String nodeId = clientId.substring(clientId.lastIndexOf(":")+1);
            // Find the tree node component with the given id
            TreeNode selectedNode =
                    (TreeNode) this.getForm1().findComponentById(nodeId);
            try {
                // Node's id property is composed of "trip" plus the trip id
                // Extract the trip id and save it for the next page
                Integer tripId = Integer.valueOf(selectedNode.getId().substring(4));
                getRequestBean1().setTripId(tripId);
            } catch (Exception e) {
                error("Can't convert node id to Integer: " +
                        selectedNode.getId().substring(4));
                return null;
    It would also be great if I can set the tree
    readonly where the user cannot toggle the expand
    property of the tree (hope this can be added to the
    tree functionality).

  • Update tree node icon, better way?

    Hi,.
    I have my own custom renderer for my JTree....such as
    public class MyTreeNodeRenderer extends JLabel implements TreeCellRenderer {
    public Component getTreeCellRendererComponent(
            JTree treeVal,
            Object valueVal,
            boolean selectedVal,
            boolean expandedVal,
            boolean leafVal,
            int rowVal,
            boolean hasFocusVal) {
            MyTreeNode node = (MyTreeNode) valueVal;
              // get the latest type for this node
            node.type = getType(node);
            if (node.type == 1) {
                    setIcon(TYPE1_ICON);
             else {
                    setIcon(TYPE_BASIC_ICON);
                   return this;
    }...intially the tree nodes have their icons, as they should...later on their "type" is updated...so instead of being 1..its now something else...so the icon should change.....but it doesnt occur fast enough...so i added this to my renderer
    public void doRepaint() {
            repaint();
            myTree.repaint();
        }basically anytime i needed to update the icon in the tree i called the doRepaint when i want the new icon to appear in the tree..that helped somewhat..but it is still kinda slow....any ideas how to do this?

    valueForPathChanged() serves different purposes as you can see from its description. You need to call treeModel.nodeChanged(node) after your node changed its "type". If you don't want to hold or don't have treeModel reference you could use tree classes from .useful library and be able to call nodeChanged() directly from a node that has been changed.
    Denis Krukovsky
    http://dotuseful.sourceforge.net/

  • Htmlb:tree differentiate between nodeclick and tree node expander click

    Hi,
    how can i differentiate between nodeclick and tree node expander (to get to its children) click in my event processing in htmlb:tree element.
    <u><b>What i am trying to achieve?</b></u>
    Onload just load root node and its immediate children.
    On node expand get the children of the current node and modify htmlb:tree table2 with additional node inofs.
    on node click  call some client function.
    But my issue is that i am not able to differentiate between node expander click and node click in my event handling. Any help on this is appreciated.
    (I am not using MVC)
    Thanks in advance.
    Regards
    Raja
    Message was edited by: Durairaj Athavan Raja

    After reading your weblog I think I understand better. I did some testing with my example.  I am using the toggle = "true", so that the page returns to the server each time an expander is selected.
    <htmlb:tree id          = "myTree1"
                  height      = "75%"
                  toggle      = "true"
                  title       = "<b><otr>EQI Reporting Tree</otr></b>"
                  width       = "90%"
                  onTreeClick = "myTreeClick"
                  table       = "<%= application->selection_model->itview                             %>" >
      </htmlb:tree>
    However I have not added any coding in my event handler to respond to the expander event.  I only respond to myTreeClick (which loads some data for the given selection).  The BSP tree element itself must be doing the hard work for me. 
      if event_id cs 'tr_myTree1'.
        data: tree_event type ref to cl_htmlb_event_tree.
        tree_event ?= htmlb_event.
        if tree_event->server_event = 'myTreeClick'.
          clear appl->message1.
          appl->selection_model->get_chart_data( appl = appl
                                                 node = tree_event->node ).
        endif.
      endif.
    I pass my entire tree defintion to the element.  It appears that it only sends visible nodes to be rendered. When the expander is selected, I don't have to do anything, the tree re-renders with only the newly visible rows. 
    I tested and turned off the toggle (toggle = "false") and my page took forever to load because it was sending all the nodes to the frontend on the first load.

  • Lables fully not visible in the Tree node

    Hi friends,
    Some text in the tree node were not visible fully.
    example : instead of documentation, it just displays doc...
    instead of Library, it just displays lib....
    And the problem doesn't appear continuously. Sometime the text is fully visible and some time it doesn't.
    If I expand the tree the text is fully visible again. I couldn't reproduce the issue continuously. I tried tree.repaint(), tree.validate(), tree.invalidate(), tree.revaidate(). but it didn't work.
    Anybody can suggest what would be the exact problem?
    Thanks in advance.

    It's hard to say without seeing the code for TreeTable. But they probably have something like an addNode mothod for the TreeTableNode which will take care of all the updates for you. If you want to do it youself, you will probably have to get the data Model (tree.getModel()???)behind the TreeTable and use one of the fire... methods on it like fireRowChanged(???) or fireTableChanged(???). I would suspect Sun would do it this way.

  • Create a tree node and show the report on the same page

    Hi,
    I have created a tree for our organization and each node represents a unit. The top one is office level and followed by division and brach.
    I have created a reprot on the same page as the tree node.
    What I want to do is:
    I would like to click a specific node and the report shows only that node and bellow. So, If I click division A and division A has two branch. my report shows only those two braches that bellong to division A.
    Can someone help me?
    Thank you

    The only way it could work is using iframes. Now OBIEE 11g would not allow iframes inside it's dashboard. It offers a dashboard object called "Embedded content" which is a restricted iframe kinda thing but unless you get this object's id from generated HTML you can change it's content dynamically. Besides, such an implementation may break with next patch. So here is an idea.
    Create a HTML page with two iframes, left one will hold all the reports with links (you can always generate a list of reports through catalog manager, open it in excel and make HTML links from it) that open report urls (in the format of ./saw.dll?GO&Path=....) in right iframe (using javascript open.window method). Once that page is working, call this page from dashboard using an action link. This is slightly twisted approach but at least it would give you what you asked for.
    About making the report list dynamic, I am afraid there are no easy answers. OBIEE provides web service that will allow the users to query catalog to get a list of reports. You can try some basic JSP to access the web service and generate the list dynamically. But that is not something I can provide here.

  • WD ABAP: selecting a tree node from program and scroll to it

    Hi guys!
    I am using a tree in Web Dynpro ABAP. I would like to select/highlight one node from the coding, without user interaction. Is it possible? I couldn't find any (obvious) way so far...
    If it is possible, then let us go a little bit further. Suppose, that the tree grew so big, that cannot fit in the container. Suppose, that you can scroll the tree up/down to see all the nodes. Now, if you mark one tree node from the coding, is it possible somehow, that you scroll the tree automatically, so that the selected node is visible?
    I am interested in any solutions within WD ABAP.
    If you can only answer one of the questions, that is also appreciated!
    Thanks for the help in advance.
    Best regards,
    Janos Kis
    Aerospace&Defense(ERP)

    Hi Thomas,
    thanks for the advice, it works, I have already tried it. The tree node in the lead selection appears highlighted.
    The scrolling doesn't work, though. I have tried to put the tree in a scroll container, and I have also tried it without (relying on the browser to scroll). Neither of them worked, it doesn't scroll to the selected node, it remains offscreen. Can you think of a way, to bring it automatically within the visible range? Ideas, anyone?
    Actually we would like to implement a search function in the tree, and show the result within the tree (highlight the node, expand, if necessary, and bring it on the screen, if off-screen)
    A negative answer is good enough for me, so that I know, that I can stop looking for a solution. Thanks in advance.
    Janos

  • Invalid B-tree node size (3,0) error - what is it??

    Yesterday I had a HDD issue on my iMac (OSX 10.5) with an 'invalid node structure' error. I eventually managed to boot into 'single user mode' and used #fsck_hfs -rf /dev/disk0s2 at the command prompt. This got OSX up and running properly again. I then repaired the permissions and the disk using the disk repair utility.
    Today, I have had a complete system freeze which necessitated a cold reboot. Since then nothing has worked. I can't boot in safe mode, single user mode or verbose mode. I tried resetting the PRAM and attempted to boot from a system install disk without initial success. After about half an hour the disk icon appeared on the screen and I could boot from the install disk. I then used the terminal to try 'fsck_hfs -rf' again. This time I got the error 'Invalid B-tree node size (3,0)'. What does this mean and what do I do now?? Most forums seem to suggest using 'Disk Warrior'. Since this costs about $170 in Australia I am unlikely to take this option. Having been unemployed for more than 5 months I am more likely to attempt replacing the drive myself. However, I'd prefer to take another approach if there is one. Any suggestions?? Would it be better to give up on replacing the internal drive and try for a bootable external HDD? Too slow?

    HI and Welcome to Apple Discussions...
    Check out TechToolPro but they might be even more $$$.
    Unfortunately, it takes a robust disk utility to repair an invalid tree node. Your best bet really is DiskWarrior
    *"Would it be better to give up on replacing the internal drive and try for a bootable external HDD? Too slow? "*
    You could use a bootable external drive but there again you are looking at an investment.
    Carolyn
    Message was edited by: Carolyn Samit

  • JSF Tree Node -Removing Green Patch

    Dear Everyone, Anyone, Someone
    I want to remove the green patch from the jsf tree component, it appears whenever we select the tree node, if we have given link from treenode, Can anyone suggest me some way.
    Please do the needful help as soon as possible.
    Regards,
    Ashish Samant

    want to remove the green patch from the jsf tree componentas u said ,, it is COMPONENET so this is a pre-made creator component that u cant chnage its attributes ,,
    instead u can extract Theam.jar file and change the icons ,, u i didnt do it before ,, but u may be find what u want there,
    hope this will help
    good luck
    Mohammed

  • Tree Nodes has White Outline/Border

    Hi,
    I'm using an ADF tree located inside a panelGroupLayout.
    The panelGroupLayout has the background color "light blue".
    At runtime each tree node is displayed with a surrounding white outline and that can only appear when you have a background color different than white (in my case the panelGroupLayout is "light blue").
    Does anybody knows how to remove that outline? or to change its color?
    Thanks,
    Alain.

    Here are the skin seletors
    tr:tree Component
    Icon Selectors
    Name      Description
    af|tree::expanded-icon      This icon is displayed before the expanded tree node.
    af|tree::collapsed-icon      This icon is displayed before the collapsed tree node.
    af|tree::no-children-icon      This icon is displayed instead of the expanded/collapsed icon, when the node has no children
    af|tree::line-icon      This icon is used as a vertical line between the nodes.
    af|tree::line-middle-icon      This icon is used as the horizontal line in the background of the expand/collapse icon of the node, in the case the node is not the last sibling of its parent node.
    af|tree::line-last-icon      This icon is used as the horizontal line in the background of the expand/collapse icon of the node, in the case the node is the last sibling of its parent node.
    af|tree::node-icon      This icon selector is used in the case the Node class has a getNodeType() method that returns the node type as string. The nodetype gets added to this selector, separated by a ':'. If the node is a container (has children) the following suffixes get added depending on the expanded/collapsed state: '-expanded' / '-collapsed'. e.g. "af|tree::node-icon:container-collapsed", "af|tree::node-icon:container-expanded", "af|tree::node-icon:noncontainer".
    Trinidad properties
    Name      Description
    -tr-show-lines      Valid values are true or false (default true). Determines whether the tree lines are displayed or not. e.g., af|tree {-tr-show-lines:false} will not show the lines of the tree.Timo

  • JTreeTable problem editing tree node

    Hi,
    Iam using the swing JTreeTable component and facing a problem. Iam displaying hierarchical data in the JTreeTable. Now I would like to provide the facility to edit a tree node. I have a TreeSelectionListener registered on the tree and a TreeModelListener registered on the DefaultTreeModel. Wheneve, I start editing a node by double clicking it the valueChanged method is called but I do not see the new value the user types in this method. I have another method setValueAt which is where I can see the new value the user has entered.
    I can set this new value to the treenode using
        node.setUserObject(newValue);However, if I do this, the next time I try to edit the same node, the editor component is painted over the tree node thus displaying an empty textfield that occupies the entire cell.
    How can I make the editor appear above the tree node with the contents loaded in it always.
    Any help is appreciated.
    cheers,
    vidyut

    You bind a mouselistener to the tree, so it has to be handled there.
    When clicking once (method should be "mouseReleased" or something, treenodes name (toString) should be .setText("");
    regards
    marco

Maybe you are looking for

  • A Hacker going at my computer?

    Hello, I think the following log indicates a hacker going at my computer, trying to gain access. Is that right? I took off the repeats, because each attempt at a username had about five or six or seven tries in a row. And also, I separated each try f

  • Updating KM Metadata properties using KM API

    Hi All, We are tring to update the custom Metadata properties using KM API from the Abstract Portal Component. We have written the below code for updating the metadata. We have checkbox called "Region" which has multiple option values like "Asia,Amer

  • MASS transaction for scheduling we need tables & fields

    Hi, We have used transaction SM30 and added BUS2013 as used table MASSFUNC with BAPI MASS_CHANGE_SCHED_AGREEMENT MASSTAB (table) and MASSFLDLST (for field selected). for the scheduling agreement of Tables and Fields please give us this data. Thanks S

  • Need help with creating invoice and list of invoices

    Hello everybody, I need to create Credit / Debit memo invoices and for this I try to use FM GN_INVOICE_CREATE in my Z program, please let me know if it is correct way to go? As well I need to create list of Credit / Debit memo invoices, how to achiev

  • Save HDR as jpeg

    I am learning how to create HDR images, but when i choose save as to try to save it as a jpeg it does not allow that as an option for file type. Is there any way to do this in Photoshop?...or do i actually have to get another program to do this?