Jtree expandPath is not working

Hi All,
I am performing following opertion on jtree
First i am taking path of selected jtree node.
i am updating jtree
then i am trying to expand jtree on the basis of selected path.
but it is not getting expanded at all.pls help
code --->
TreePath treePath=tree.getSelectionPath().getParentPath();
// below line refreshing tree with new value
TreeStructure.CreateTreeStructure(connDialog.getConnection(), tree, connDialog.getServerName().getText());
tree.expandPath(treePath);
// tree.setSelectionPath(treePath);
tree.setVisible(true);

do u got the solution for ur problem?
if no
this thread show the error source
http://forum.java.sun.com/thread.jspa?threadID=674858
else
tell me the solution

Similar Messages

  • Jtree expand all not working

    I have a very large jtree, that at it second level gets loaded from a JDOm file.
    The problem is I am having a problem expanding all the nodes under a
    particular node. I need an expandAll method. Nothing I have tried has
    expanded beyond the child level.
    After a few permutations my code right now is
    public void expandAll(DefaultMutableTreeNode node)
    Enumeration list = node.breadthFirstenumeraion();
    while (list.hasMoreElements())
    TreePath treePath = new
    TreePath(((DefaultMutableTreeNode)list.nextElement()).getPath()))
    tree_m.expandPath(treePath);
    Am i missing something about expandPath?
    I even use the code from JTree example to the reload the model.
    But it still only shows the nodes children, not the children's children....etc.

    Hi!
    You can try these methods where treeRoot is the root node of the tree:
    * Collapses the function group tree.
    public void collapseAll() {
    for (int i = treeRoot.getChildCount(); i > 0; i--) {
    tree.collapseRow(i);
    * Collapses the function group tree.
    public void expandAll() {
    for (int i = treeRoot.getChildCount(); i > 0; i--) {
    tree.expandRow(i);
    /Malin

  • CFIMAGE not working when there is a . in the file path?

    I’m trying to use CFIMAGE for the first time and running into an issue. I am guess it is because my path has a period in it but I am not sure and I am not sure how to get around it if that is indeed the problem.
    I’m using ExpandPath to get the directory path but I have tried it other way with the same result. The path is
    C:\Websites\mywebsite.com\www\images
    I’m just trying to take a file in the C:\Websites\mywebsite.com\www\images\temp directory and resize it then rename it to the memberid with 300 on the end and save it to this directory C:\Websites\mywebsite.com\www\images\members
            <cfimage
            action = "resize"
            height = ""
            source = "#ExpandPath("..\images")#\temp\#TempFileName#"
            width = "300"
            optional
            destination = "#ExpandPath("..\images")#\members\"
            name = "#ARGUMENTS.MemberID#300"
            format = "jpg"
            overwrite = "yes">
    I keep getting the folowing error.
    The com\www\images\members\ image format is not supported on this operating system.
    Any ideas?

    was the fact that I ahd both destination and name being used
    at the same time.
    Using both "destination" and "name" works fine for me on windows. Though as I said, it is usually more common to use one or the other (not both).
    all I did was copy and paste
    from Adobe's example.
    Given the fact that your code contained the word "optional", you may have inadvertently copied a usage/syntax description rather an actual code example. Most of the descriptions contain the word "optional" to separate the mandatory and optional attributes. They are just descriptions not working code. Look for the actual code examples further down in the page (usually in a mono-font like courier).

  • ExecuteUpdate() is not working

    I have a Statement and I am calling the executeUpdate() method to execute some SQL into my database. It says I'm using it from a static context, while my calling method is not!
    public void createTable()     {
    // describe Connection con, open connection pool, then
    Statement statement = con.createStatement(
         ResultSet.TYPE_SCROLL_SENSITIVE,
         ResultSet.CONCUR_UPDATABLE          );
    Statement.executeUpdate(     "CREATE TABLE newTable ();"     );
    non-static method executeUpdate(java.lang.String) cannot be referenced from a static context
    Statement.executeUpdate(     "CREATE TABLE newTable ();"     );
    I'm out of clues.

    Duh! At 2AM one is not working at optimum capacity...
    Additional question, I hope this one is not out of line.
    How can I create an empty table? The code above is not working for that. Does not give an error but I can't see a new table. If I add some code to create some columns, the table appears, but not the empty () one.
    And is it possible to create a table without a name? The GUI would prompt the user for the name after the creation (it would actually have to appear on a JTree component, with the focus on the name of the table selected)..

  • Custom TreeCellRenderer not working in Program

    The following 2 lines set my TreeCellRenderer
    FSDirectoryCellRenderer renderer1 = new FSDirectoryCellRenderer();
    jtree.setCellRenderer(renderer1);
    Rendering is not working in the Below Program. But If I comment the above 2 lines the default rendering is working. There is a probelm with my rendering class FSDirectoryCellRenderer which I am not able to figure out. PLease help me out
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextField;
    import javax.swing.JTree;
    import javax.swing.UIManager;
    import javax.swing.border.BevelBorder;
    import javax.swing.border.SoftBevelBorder;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeCellRenderer;
    import javax.swing.tree.TreePath;
    public class UniversityLayout extends JFrame {
         private JTree jtree = null;
         private DefaultTreeModel defaultTreeModel = null;
         private JTextField jtfStatus;
         public UniversityLayout() {
              super("A University JTree Example");
              setSize(300, 300);
              Object[] nodes = buildJTree();
              DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
              renderer.setOpenIcon(new ImageIcon("opened.gif"));
              renderer.setClosedIcon(new ImageIcon("closed.gif"));
              renderer.setLeafIcon(new ImageIcon("leaf.gif"));
              jtree.setCellRenderer(renderer);
              jtree.setShowsRootHandles(true);
              jtree.setEditable(false);
              jtree.addTreeSelectionListener(new UTreeSelectionListener());
              FSDirectoryCellRenderer renderer1 = new FSDirectoryCellRenderer();
              jtree.setCellRenderer(renderer1);
              JScrollPane s = new JScrollPane();
              s.getViewport().add(jtree);
              getContentPane().add(s, BorderLayout.CENTER);
              jtfStatus = new JTextField(); // Use JTextField to allow copy operation
              jtfStatus.setEditable(false);
              jtfStatus.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
              getContentPane().add(jtfStatus, BorderLayout.SOUTH);
              TreePath path = new TreePath(nodes);
              jtree.setSelectionPath(path);
    //          jtree.scrollPathToVisible(path);
         class FSDirectoryCellRenderer extends JLabel implements TreeCellRenderer {
              private Color textSelectionColor;
              private Color textNoSelectionColor;
              private Color backgroundSelectionColor;
              private Color backgroundNoSelectionColor;
              private boolean sel;
              public FSDirectoryCellRenderer() {
                   super();
                   textSelectionColor = UIManager.getColor("Tree.selectionForeground");
                   textNoSelectionColor = UIManager.getColor("Tree.textForeground");
                   backgroundSelectionColor = UIManager
                             .getColor("Tree.selectionBackground");
                   backgroundNoSelectionColor = UIManager
                             .getColor("Tree.textBackground");
                   setOpaque(false);
              public Component getTreeCellRendererComponent(JTree tree, Object value,
                        boolean selected, boolean expanded, boolean leaf, int row,
                        boolean hasFocus) {
                   DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
                   Object obj = node.getUserObject();
                   setText(obj.toString());
                   if (obj instanceof Boolean) {
                        setText("Loading");
                   if (obj instanceof NodeIconData) {
                        NodeIconData nodeIconData = (NodeIconData) obj;
                        if (expanded) {
                             setIcon(nodeIconData.getExpandedIcon());
                        } else {
                             setIcon(nodeIconData.getNormalIcon());
                   } else {
                        setIcon(null);
                   setFont(jtree.getFont());
                   setForeground(selected ? textSelectionColor : textNoSelectionColor);
                   setBackground(selected ? backgroundSelectionColor
                             : backgroundNoSelectionColor);
                   sel = selected;
                   return this;
         private Object[] buildJTree() {
              Object[] nodes = new Object[4];
              DefaultMutableTreeNode root = new DefaultMutableTreeNode(new College(1, "College"));
              DefaultMutableTreeNode parent = root;
              nodes[0] = root;
              DefaultMutableTreeNode node = new DefaultMutableTreeNode(new College(2, "Class 1"));
              parent.add(node);
              parent = node;
              parent.add(new DefaultMutableTreeNode(new College(3, "Section A")));
              parent.add(new DefaultMutableTreeNode(new College(4, "Section B")));
              parent = root;
              node = new DefaultMutableTreeNode(new College(5, "Class 2"));
              parent.add(node);
              nodes[1] = node;
              parent = node;
              node = new DefaultMutableTreeNode(new College(6, "Science"));
              parent.add(node);
    //          nodes[2] = node;
              parent = node;
              parent.add(new DefaultMutableTreeNode(new College(7, "Computer Science")));
              parent.add(new DefaultMutableTreeNode(new College(8, "Information Science")));
              parent = (DefaultMutableTreeNode)nodes[1];
              node = new DefaultMutableTreeNode(new College(9, "Arts"));
              parent.add(node);
              nodes[2] = node;
              parent = (DefaultMutableTreeNode)nodes[2];
              parent.add(new DefaultMutableTreeNode(new College(10, "Drawing")));
              node = new DefaultMutableTreeNode(new College(11, "Painting"));
              parent.add(node);
              nodes[3] = node;
              parent = (DefaultMutableTreeNode)nodes[1];
              parent.add(new DefaultMutableTreeNode(new College(12, "Telecom")));
              defaultTreeModel = new DefaultTreeModel(root);
              jtree = new JTree(defaultTreeModel);
              return nodes;
         public static void main(String argv[]) {
              UniversityLayout frame = new UniversityLayout();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
         class UTreeSelectionListener implements TreeSelectionListener {
              public void valueChanged(TreeSelectionEvent e) {
                   TreePath path = e.getPath();
                   Object[] nodes = path.getPath();
                   String status = "";
                   for (int k = 0; k < nodes.length; k++) {
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) nodes[k];
                        College nd = (College) node.getUserObject();
                        status += "." + nd.getId();
                   jtfStatus.setText(status);
    class College {
         protected int id;
         protected String name;
         public College(int id, String name) {
              this.id = id;
              this.name = name;
         public int getId() {
              return id;
         public String getName() {
              return name;
         public String toString() {
              return name;
    }

    It works fine for me (after commenting out the part about NodeIconData, whose source you didn't provide). What is the behavior you expect to see but don't? Is it that when you click on a tree node, it doesn't appear "selected?"
    Why not extends DefaultTreeCellRenderer? You appear to be doing minimal configuring (sometimes changing the text and/or icon of the node).
         class FSDirectoryCellRenderer extends DefaultTreeCellRenderer {
              public FSDirectoryCellRenderer() {
                   super();
                   setOpaque(false);
              public Component getTreeCellRendererComponent(JTree tree, Object value,
                        boolean selected, boolean expanded, boolean leaf, int row,
                        boolean hasFocus) {
                   super.getTreeCellRendererComponent(tree, value, selected, expanded,
                                       leaf, row, hasFocus);
                   DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
                   Object obj = node.getUserObject();
                   setText(obj.toString());
                   if (obj instanceof Boolean) {
                        setText("Loading");
    //               if (obj instanceof NodeIconData) {
    //                    NodeIconData nodeIconData = (NodeIconData) obj;
    //                    if (expanded) {
    //                         setIcon(nodeIconData.getExpandedIcon());
    //                    } else {
    //                         setIcon(nodeIconData.getNormalIcon());
    //               } else {
                        setIcon(null);
                   return this;
         }

  • Extreme JTree.expandPath frustration

    I've read through about 80 posts on this subject and cannot solve my problem. I am trying to dynamically select a node in a JTree. I'm using a custom TreeModel to model an XML file. I select the node with the following code:
    jTree.setExpandsSelectedPaths(true);
    jTree.setSelectionPath(treePath);
    jTree.expandPath(treePath);
    jTree.scrollPathToVisible(treePath);I know the node is being selected b/c a subsequent action is taken via the tree listener, and a call to jTree.getSelectionPath() shows the expected treePath. The problem is that graphically the treePath is niether expanded nor highlighted.
    If I call jTree.getRowForPath(jTree.getSelectionPath())
    -or- jTree.getRowForPath(treePath) I get "-1" which according to the Javadocs can only happen "if any of the elements in path are hidden under a collapsed parent". But I've eliminated this possibility by expanding the entire tree.
    Can anyone please help.
    Thanks,
    bb

    My problem turned out to be a problem in a custom equals method. A cruel bug elsewhere in the code was fooling me into thinking the listener was triggering correctly.
    I'm not sure I understand your question but this might help. The TreePath[] needs to include the Node objects that comprise the path you want to select. In my case I have no reference to the actual Nodes so I have to create a new TreePath[] that has identical nodes (but not the actual nodes). The actual nodes and the identical nodes do contain a reference to the same encapsulated object. I can therefore walk the tree row-by-row and compare the object encapsulated by the actual Node to the object encapsulated by the identical node. When a match is found I expand that row and continue the search until I reach the end of the TreePath[]. Here is roughly what the code might look like:
    "path" is the identical TreePath, "getElement()" returns a reference to the encapsulated object.static void selectNode(TreePath path) {
         TreePath select = path;
         TreePath rowPath = null;
         int row = 0;
         int i = 1;                    // ignore the root
         Element element1, element2;          
         while (row < tree.getRowCount()) {
              while (i < select.getPathCount()) {
                   rowPath = tree.getPathForRow(row);
                   if(i >= rowPath.getPathCount()) i = rowPath.getPathCount()-1;
                   element1 = ((AdapterNode)(rowPath.getPathComponent(i))).getElement();
                   element2 = ((AdapterNode)(select.getPathComponent(i))).getElement();
                   if(element1.equals(element2)) {
                        if(i == select.getPathCount() - 1) break;
                        tree.expandRow(row); 
                        i++;
                   row++;
              break;
         tree.setSelectionRow(row);
         tree.scrollRowToVisible(row);
    }

  • POST method of form not working

    I am using the post method in a HTML form the action
    attribute points to a pl/sql procedure and it is not working
    i get
    SIGNATURE (parameter names) MISMATCH
    VARIABLES IN FORM NOT IN PROCEDURE:
    NON-DEFAULT VARIABLES IN PROCEDURE NOT IN FORM:
    in IE 5.0
    the same code works if client is Netscape !!
    and if i change to GET method that too works
    any suggestions
    tia,
    -amol

    Hi,
    I have the following scenario:
    A Swing-Application is using JClient to bind to bc4j. The JUStatusBar works fine for the forms which have an iterator. But if I show a form with a JTree, e.g., I don't want the message "3 out of 4000 rows" to be displayed in the status bar... because it is a tree...You can install a custom StatusBar and override displayStatus() methods to ignore iterBinding that's bound to JTree.
    something like:
    JUStatusBar statusBar = new JUStatusBar(..)
    public void displayStatus(JUIteratorBinding bind, String msg, Object[] params)
    if bind == treebind or an iterator that's displayed in the tree then return
    else call super.
    I thought, the status bar should implement this behaviour, it displays a "iterator released" message, but the label from the form before the JTree-form was coming up isn't cleaned up.
    Any suggestion for me what to do?
    Torsten.

  • Custom Scriptmaps Not Working in DW6

    I use custom scriptmaps. I have modified every version of DW going back to Macromedia. The process is outlined here:
    http://helpx.adobe.com/dreamweaver/kb/change-add-recognized-file-extensions.html
    I made these changes for DW6 and I can open the files, but the soure code formatting is not working.
    DW6 does not recognize the page as HTML.
    Thank you.

    It works fine for me (after commenting out the part about NodeIconData, whose source you didn't provide). What is the behavior you expect to see but don't? Is it that when you click on a tree node, it doesn't appear "selected?"
    Why not extends DefaultTreeCellRenderer? You appear to be doing minimal configuring (sometimes changing the text and/or icon of the node).
         class FSDirectoryCellRenderer extends DefaultTreeCellRenderer {
              public FSDirectoryCellRenderer() {
                   super();
                   setOpaque(false);
              public Component getTreeCellRendererComponent(JTree tree, Object value,
                        boolean selected, boolean expanded, boolean leaf, int row,
                        boolean hasFocus) {
                   super.getTreeCellRendererComponent(tree, value, selected, expanded,
                                       leaf, row, hasFocus);
                   DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
                   Object obj = node.getUserObject();
                   setText(obj.toString());
                   if (obj instanceof Boolean) {
                        setText("Loading");
    //               if (obj instanceof NodeIconData) {
    //                    NodeIconData nodeIconData = (NodeIconData) obj;
    //                    if (expanded) {
    //                         setIcon(nodeIconData.getExpandedIcon());
    //                    } else {
    //                         setIcon(nodeIconData.getNormalIcon());
    //               } else {
                        setIcon(null);
                   return this;
         }

  • Problem, errors in JTree.expandPath(TreePath)

    I got errors when doing JTree.expandPath(TreePath), and I have no idea, whats wrong with my code, I printed out the TreePath, and it looks alright, I just dont know why it doesnt work.

    Now, if only this answer wasn't three years late, i'm sure you'd be getting all the dukes you deserve. Seriously, why resurrect a three year old thread with a potentially incorrect answer?

  • SetInvokesStopCellEditing(true) not working

    hi
    setInvokesStopCellEditing(true) in jTree is not working.
    when i set it true it should save the data entered in textfield but it doesnot
    any help
    thanks

    I've found that setting it to true makes JTree save the changes if you click on another node during editing, but hitting the Esc key discards changes regardless of this setting.

  • Not work tablet UI on Prestigio 5080 PRO tablet

    I read that browser.ui.layout.tablet = "1" can fix this problem. But it not works. I can work only in pnone interface that is not good for my 8'' tablet.

    Would it be possible for you to share the problematic pdf and OS information  with us at [email protected] so that we may investigate?
    Thanks,
    Adobe Reader Team

  • Why self-defined access sequences of free goods can not work?

    Hi gurus,
    I have maintained access sequences of free goods self-defined.but when i creat the SO it does not work!
    when i used the standard access sequences ,it is OK .
    Can anybody tell me why?
    thanks in advance

    Dear Sandy,
    Go to V/N1 transaction select your self defined access sequence then go in to the accesses and fields and check all fields are activated.
    Make sure that these fields are flowing in your sales order.
    I hope this will help you,
    Regards,
    Murali.

  • Adobe bridge raw not working with windows vista in photoshop cc, why?

    adobe bridge raw not working in photoshop cc, is there a fix?

    Your sure your using photoshop cc on windows vista?
    I was under the impression that photoshop cc would not even install on windows vista.
    What version of camera raw do you have?
    In photoshop under Help>About Plugin does it list Camera Raw and if so which version is it?
    (click on the words Camera Raw to see the version)
    Camera raw doesn't work if it's a camera raw file or some other file type such as jpeg or tif?
    What camera are the camera raw files from?
    Officially camera raw 8.3 is the latest version of camera raw that will work on windows vista.

  • Adobe Bridge CS5 in windows 7 not working?

    Adobe Bridge CS5 in windows 7 not working. I was using bridge perfectly for last 2 years. It stops working since 3 days. I tried to install updates. Showing some error to install.
    Tried to install creative cloud..again some error. Error code : 82
    Could you please advice how I can fix my adobe bridge.

    https://www.youtube.com/watch?v=xDYpTOoV81Q&feature=youtu.be
    please check this video I uploaded..this is what happens when I click adobe bridge.. just blinks and go off. bridge not working on task manager

  • ADOBE CLOUD ON MY DESKTOP WILL NOT WORK. IT LOADS UP BUT NOTHING FILLS THE WINDOW

    ADOBE CLOUD ON MY DESKTOP WILL NOT WORK. IT LOADS UP BUT NOTHING FILLS THE WINDOW

    BLANK Cloud Screen http://forums.adobe.com/message/5484303 may help
    -and step by step http://forums.adobe.com/thread/1440508?tstart=0
    -and http://helpx.adobe.com/creative-cloud/kb/blank-white-screen-ccp.html

Maybe you are looking for

  • Page not getting displayed when placed in sub directory?

    Dear all, I am trying to make a simple page in 10.1.3.5 jdeveloper using ADF BC as template.I have defined a workspace with Model and ViewController as the projects.I am encountering a strange problem.When I define a JSF JSP page in ViewController di

  • What is S.M.A.R.T. and how to read S.M.A.R.T. attributes

    Read the bottom for updated information/amendments Hi everyone, S.M.A.R.T. is Self-Monitoring, Analysis and Reporting Technology. [size=15]1. S.M.A.R.T. info websites[/size] OK, now we all know what S.M.A.R.T. stands for. For more details about S.M.A

  • Getting error while running the Interface using AGENT

    Hi All, i am not able to run the interface using Agent service which running in the another machine, while running i am getting error message like java.lang.Exception: Error during Session launching      at com.sunopsis.dwg.dbobj.SnpSession.remoteExe

  • Online Number out of order??????

    I have a Skype number that I use for my business and the subscription is due today. I paid the full amount on 28th August and Skype acknowledged receipt, but now my Skype number is not working so my customers cannot phone me! This is disastrous four

  • Seeking advice for timer design

    Hi, I am designing a timer application with Flex Builder 3 which is basically a stop watch that will remember when it was started if the page is reloaded (on a different computer, for instance). My original plan was to use JavaScript and mySQL but I'