New Jtree node not displaying

I have created a Jtree with some default elements. Later on I add new ones with the: treeModel.insertNodeInto() method. However the new node is not displayed. If I colapse and expand the tree it's still not displayed. Is there anything I need to do to tell the tree to refresh itself.

Here are some more details that might help isolate this refresh problem. I've got a custom JPanel that displays a JTree. The root of JTree has 2 children: A, and B. You can dynamically add a Foler to A, where Folder implements TreeNode. You can drag elements from the tree rooted at B to a Batch. I've subclassed JTree to handle the drag and drop.
public class Folder implements MutableTreeNode {
public class MyPanel extends JPanel {
    private DefaultMutableTreeNode root, A, B;
    private MyTree tree;
    public MyPanel() {
        root = new DefaultMutableTreeNode();
        A = new DefaultMutableTreeNode("A");
        B = new DefaultMutableTreeNode("B");
        root.add(A);
        root.add(B);
        tree = new MyTree(root);
    // this method refreshes the tree correctly!!!
    public void addFolder(Folder f) {
        A.insert(f, A.getChildCount());
        // let the model know that the node was inserted
        DefaultTreeModel model = (DefaultTreeModel)tree.getModel();
        model.nodesWereInserted(A, new int[] {A.getChildCount() - 1});
        tree.makeVisible(new TreePath(new Object[] {root, A, f}));
public class MyTree extends JTree
implements DropTargetListener, DragSourceListener, DragGestureListener {
    public MyTree(DefaultMutableTreeNode root) {
        super(root);
    // method that handles the drop
    // DnDNode is a subclass of MutableTreeNode that implements Transferable
    // this method does _not_ update the UI correctly
    public void drop(DropTargetDropEvent dtde) {
        try {
            Transferable t = dtde.getTransferable();
            if ( t.isDataFlavorSupported(...) ) {
                Point p = dtde.getLocation();
                TreePath path = getPathForLocation(p.x, p.y);
                if (path != null && path.getLastPathComponent() instanceof Folder) {
                    dtde.acceptDrop(DnDConstants.ACTION_COPY);
                    Folder parent = (Folder)path.getLastPathComponent();
                    DnDNode child = (DnDNode)t.getTransferData(...);
                    parent.insert(child, parent.getChildCount());
                    model.nodesWereInserted(parent, new int[] {parent.getChildCount() - 1});
                    makeVisible(path.pathByAddingChild(child));
                    dtde.getDropTargetContext().dropComplete(true);
                else dtde.rejectDrop();
            else dtde.rejectDrop();
        catch(Exception ioe) {... }
}To sum up, the UI is correctly refreshed when I call the addFolder() method in the class MyPanel. The UI does not refresh correctly after the drop() method in the MyTree class. Even though the same methods are used for both insertions.

Similar Messages

  • How to force JTree to not display  the leaves

    Hi
    Is there anyway to force JTree to not display the "end nodes" so to speak.
    What I want is that if a node is a leaf and is not allowed to have children
    I do not want the JTree to display them.
    I need this to build a component for a custom file system view like Windows Explorer
    which contains a tree with folders on the left and and contents of the currently selected( expanded)
    folder on the right. But Explorer does not display any files in the left pane, only folders.
    So I need to implement the same in my component

    This will give you some things to think aboutimport java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.util.*;
    public class Test3 extends JFrame {
      Vector nodes = new Vector();
      DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
      DefaultTreeModel dtm = new DefaultTreeModel(root);
      JTree jt = new JTree(dtm);
      JCheckBox jcb = new JCheckBox("Allow Expansion");
      Random r = new Random();
      int nodeCount=0;
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        addNodes(root,0);
        content.add(jcb, BorderLayout.NORTH);
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.addTreeWillExpandListener(new TreeWillExpandListener() {
          public void treeWillCollapse(TreeExpansionEvent tse) {}
          public void treeWillExpand(TreeExpansionEvent tse) throws ExpandVetoException{
            if (jcb.isSelected()) return;
            TreeNode tn = (TreeNode)tse.getPath().getLastPathComponent();
            Enumeration e = tn.children();
            boolean expand = false;
            while (!expand && e.hasMoreElements()) {
              if (((TreeNode)e.nextElement()).getChildCount()!=0) expand  = true;
            if (!expand) throw new ExpandVetoException(tse);
        setSize(400, 400);
      private void addNodes(DefaultMutableTreeNode parent, int level) {
        int cnt = r.nextInt(3)+3-level;
        for (int i=0; i<cnt; i++) {
          DefaultMutableTreeNode node = new DefaultMutableTreeNode("Node"+nodeCount++);
          parent.add(node);
          nodes.add(node);
          addNodes(node, level+1);
      public static void main(String[] args) { new Test3().setVisible(true); }
    }

  • Help JTree is not displaying inside of JFrame

    Hello,
    I have a frame application, inside the frame I have a jtable. when the users double click on a row from the table. I want to display an internalJFrame, which contain a tree with data on it. I try different combination with no luck. Below is the code where I am calling the internalJFrame and the internalJFrame code. Thank you for your help.
    //calling internal frame (hierarchicalPanel)
    if (e.getClickCount () == 2) {
    try {
    String tempID = jTable1.getValueAt(jTable1.getSelectedRow(), 0).toString();
    selectedID = Long.parseLong(tempID);
    }catch (NumberFormatException nfe) {
    hierarchicalPanel = new HierarchicalPanel(selectedID);
    hierarchicalPanel.setAddedToDesktop (true);
    desktop.add(hierarchicalPanel);
    hierarchicalPanel.setVisible(true);
    //internal frame class
    private HierarchalView hierarchalView;
    //tree stuff
    private DefaultMutableTreeNode root = null;
    private DefaultTreeModel treeModel;
    private CommRecord commRec;
    private InstalledComponent installedAComponent;
    private InstalledComponent installedZComponent;
    private static boolean addedToDesktop;
    /** Creates new form Hierarchical */
    public HierarchicalPanel(long sipID) {
    initComponents();
    hierarchalView = new HierarchalView();
    createNodes(sipID);
    createTree();
    * create a JTree
    public void createTree() {
    jTree1 = new JTree(treeModel);
    jTree1.putClientProperty("JTree.lineStyle", "Angled");
    jTree1.getSelectionModel()
    .setSelectionMode(TreeSelectionModel
    .DISCONTIGUOUS_TREE_SELECTION);
    jTree1.setOpaque(false);
    // tree.setCellRenderer(new AlphaRenderer());
    jTree1.expandRow(0);
    //this.llistenToTree(treeModel);
    //popup();
    //return tree;
    * Add nodes to model
    public void createNodes(long sipID){
    DefaultMutableTreeNode root = null;
    DefaultMutableTreeNode node = null;
    DefaultMutableTreeNode child = null;
    commRec = hierarchalView.getComRec(sipID);
    long aComponentID = commRec.getSiteAInstalledComponent().getId();
    long zComponentID = commRec.getSiteZInstalledComponent().getId();
    long comID = commRec.getId();
    //String desc = getSipData(sipID).getCustomerName();
    root = new DefaultMutableTreeNode("SIP ID" + sipID);
    treeModel = new DefaultTreeModel(root);
    node = new DefaultMutableTreeNode("Communication ID");
    root.add(node);
    child = new DefaultMutableTreeNode("A InstallComponent " + aComponentID );
    node.add(child);
    child = new DefaultMutableTreeNode("Z InstallComponent " + zComponentID );
    node.add(child);
    System.out.println("finish inside node********");
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {
    jPanel1 = new javax.swing.JPanel();
    jTree1 = new javax.swing.JTree();
    jPanel1.setLayout(new java.awt.BorderLayout());
    jPanel1.setMinimumSize(new java.awt.Dimension(5, 100));
    jPanel1.setPreferredSize(new java.awt.Dimension(5, 100));
    jTree1.setMaximumSize(new java.awt.Dimension(78, 50));
    jTree1.setMinimumSize(new java.awt.Dimension(80, 20));
    jTree1.setPreferredSize(new java.awt.Dimension(100, 50));
    jPanel1.add(jTree1, java.awt.BorderLayout.CENTER);
    getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
    pack();
    * Called whenever the value of the selection changes.
    * @param e the event that characterizes the change.
    public void valueChanged(TreeSelectionEvent e) {
    /** Getter for property addedToDesktop.
    * @return Value of property addedToDesktop.
    public boolean isAddedToDesktop () {
    return addedToDesktop;
    /** Setter for property addedToDesktop.
    * @param addedToDesktop New value of property addedToDesktop.
    public void setAddedToDesktop (boolean addedToDesktop) {
    this.addedToDesktop = addedToDesktop;

    You forgot insert it into treeModel

  • JTree nodes not updating

    I have a JTree which the nodes are changed from within an actionPerfomed method. However, they are not updating on the screen until a user clicks on a node. Also, the length of the selection box does not change on the tree, so text can be clipped. The code from my actionPerformed is as follows
    DefaultMutableTreeNode node = findObjectInTree( event.getOriginalObject() );
    if ( node != null ) {
    node.setUserObject( event.getObject() );
    DefaultTreeModel model = ( DefaultTreeModel ) titleTree.getModel();
    model.nodeChanged( node );
    TreePath path = new TreePath( node.getPath() );
    titleTree.scrollPathToVisible( path );
    titleTree.setSelectionPath( path );

    I'm not sure what that 'event.getOriginalObject()' stuuf is, but maybe this will helpimport java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.util.*;
    public class Test3 extends JFrame implements Runnable {
      Vector nodes = new Vector();
      DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
      DefaultTreeModel dtm = new DefaultTreeModel(root);
      JTree jt = new JTree(dtm);
      Random r = new Random();
      int nodeCount=0;
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        addNodes(root,0);
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        setSize(400, 400);
        new Thread(this).start();
      private void addNodes(DefaultMutableTreeNode parent, int level) {
        int cnt = r.nextInt(3)+5-level;
        for (int i=0; i<cnt; i++) {
          DefaultMutableTreeNode node = new DefaultMutableTreeNode("Node"+nodeCount++);
          parent.add(node);
          nodes.add(node);
          addNodes(node, level+1);
      public static void main(String[] args) { new Test3().setVisible(true); }
      public void run() {
        while (true) {
          try { Thread.sleep(2000); } catch (Exception e) {}
          DefaultMutableTreeNode randNode = (DefaultMutableTreeNode)
                                         nodes.get(r.nextInt(nodes.size()));
          randNode.setUserObject(randNode.getUserObject()+"!");
          dtm.nodeChanged(randNode);
          TreePath tp = new TreePath(randNode.getPath());
          jt.scrollPathToVisible(tp);
          jt.setSelectionPath(tp);
    }

  • New favicon will not display in Firefox, but does display in Safari

    I am working on a new website and uploaded the favicon.ico into the root folder (Go Daddy). The favicon appears when I use Safari, not does not appear in Firefox... I have a mac OSX version 10.5 I have cleared the history and cache too. Any thoughts?

    I have this problem too. I've just loaded my favicon.ico into my root folder and it shows next to the site url in latest Safari 5.0.5, but not in Firefox 3.6.17 - neither next to the site url nor on the page name tab.
    Firefox also does not show the favicon in the Tools > Page Info > Media tab, although this does list just three of the many jpgs and pngs within its folders. I've just added the favicon.ico to the folder where it does see a jpg and png, but no joy, still not displayed. See attached png.
    How do I overcome this problem? Is there a plugin that resolves this issue? It would be nice to have some color in the page name tabs. Many sites, such as this one, do have their favicons displayed by Firefox...

  • Report deployed to new server does not display static image

    Hi,
    We have several web sites on a server running Windows Server 2008 R2 Standard, SP1, 64-bit.  It has installed .NET Framework 4 Client Profile and Extended, ver. 4.0.30319 (according to Control Panel->Programs, as well as c:\Windows\Microsoft.NET\Framework).  Two of the sites use many Crystal Reports, most of which include a static image as a logo. This image is embedded in each report; there is no stand-alone image file that gets deployed.
    Recently, we migrated to a new server, running the same version of Windows & .NET Framework.  As near as we can tell, the 2 servers are nearly identical, as far as configuration and permissions, etc. One notable exception is the DefaultAppPool, which is Classic on the original server and Integrated on the new. (When I changed the new server to Classic, the apps failed to run properly.)  The other exception is the old server is on a stand-alone box, while the new server is a virtual machine.
    For one of the apps on the new server, the embedded logo images are not displaying on the page.  Instead, there is a little red X with the word "Image".  For the other app on the new server, the reports display fine.  Furthermore, if I copy one of the "broken" rpt files from the "broken" app to the "good" app, the report displays correctly!  And of course, the same file displays correctly in all circumstances on the old server.
    This suggests to me that there is not a problem with the report file, per se', but rather with the environment to which it is deployed.  Permissions?  If so, where?
    Any suggestions would be much appreciated.
    Thanks.
    --d

    The search string 'crystal red x net' (search box in top right corner) should return a number of KBAs, docs, blogs, etc. See if any of those help.
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • New tabs do not display

    my firefox just updated today
    all my existing tabs loaded correctly and are present, however I cannot make new tabs- they do not display or load by any command and i cannot toggle over to them when switching through existing tabs.
    it is as if the new tab command is not executing a new tab now.
    a site on an existing tab can create another tab, such as what mozilla did while i was searching for answers to this question, but i cannot make any new tabs via keyboard or menu command.
    i need to make new tabs and not use existing tabs which are already in use!

    hello, can you try to replicate this behaviour when you launch firefox in safe mode once? if not, maybe an addon is interfering here... (reports by other affected users indicate that this might be caused by various toolbar addons)
    [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]

  • APEX - New Installation - Pages not displaying correctly

    I installed APEX 3.0.1 on my XP machine, which also has Oracle Enterprise 10.2.0.1 installed. I checked the installation log - no errors.
    I performed the following to get it working via the Embedded PL/SQL Gateway:
    begin
    dbms_xdb.sethttpport(8080);
    end;
    alter user anonymous account unlock;
    begin
    dbms_epg.create_dad('APEX','/apex/*');
    dbms_epg.set_dad_attribute('APEX','database-username','ANONYMOUS');
    dbms_epg.set_dad_attribute('APEX','default-page','apex');
    dbms_epg.set_dad_attribute('APEX','document-table-name','wwv_flow_file_objects$');
    dbms_epg.set_dad_attribute('APEX','document-path','docs');
    dbms_epg.set_dad_attribute('APEX','nls-language','american_america.al32utf8');
    dbms_epg.set_dad_attribute('APEX','document-procedure','wwv_flow_file_mgr.process_download');
    dbms_epg.set_dad_attribute('APEX','request-validation-function','wwv_flow_epg_include_modules.authorize');
    end;
    begin
    dbms_epg.AUTHORIZE_DAD('APEX', 'ANONYMOUS');
    end;
    However, when I go to the login page, the images are not displayed and when I try to use some of the other links, I repeatedly get prompted for a password for XDB.
    The page error is:
    Line: 40
    Char: 1
    Error: Object expected
    Code: 0
    URL: http://gtlt01479:8080/apex/.......
    Can anyone shed some light on this for me?

    Hi Joseph,
    the installation instruction isn't really clear on that, but "Embedded PL/SQL Gateway" is not supported for pre-11g databases. See http://www.oracle.com/technology/products/database/application_express/html/3.0_fsps.html#08
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Description of nodes not displayed RSA3: 0CUST_SALES_TID_LKDH_HIER (VDH2N)

    Descriptions where maintained with R/3 tcode VDH2N. With tcode RSA3: 0CUST_SALES_TID_LKDH_HIER the descriptions are not displayed.
    The fm VHBW_HIERARCHY_CATALOG_LKDH sets a technical text, but we want the maintained description.
    Why is this not standard, or do I oversean, or miss something?
    Thanks for all the advise, etc.
    Kind Regards,
    Peter Weldink

    and the solution was?

  • New storage node not taking any traffic

    Hi all,
    I have a strange situation where we introduced a few new storage nodes into a cluster that already had about 190 storage nodes running. From what I can tell, the nodes joined the cluster just fine (I see them listed as part of the cluster according to the JMX node, and their logs indicate as much).
    The problem is that they don't seem to take any traffic. Their get and put counts are at 0, their size is at 0. They have the exact same configuration as every other node running in the cluster, and are even running on the same box as other storage nodes (so shouldn't be networking related).
    Any ideas as to what could cause this to happen? They nodes have been up for days now and nothing has changed. There isn't anything along the lines of errors in the storage node logs or anything that seems to be related or would indicate a problem.
    Thanks,
    Chris

    Hi Chris,
    What is your partition count set to, is it still the default of 257? If it is then this could be your problem, I have had issues in the past with partition counts too close to the cluster size. For a cluster of 190 nodes you really need a big partition size, we have 8191 on a 170 node cluster.
    JK

  • New Field value not displayed in "My own activities" of CRM 5.0 Own tab

    Hi.
    I have a scenario where in we have added a new field to "My open activities" in CRM 5.0 Own tab.
    However the value of the field for various transactions is getting displayed only for one particular user and not for all the users.
    what may be the reason for this?!!!!!!
    The only user who is getting the output properly, the user ID of his was replication based on similar roles to check whether it was issue related with roles. But the output was not obtained even with the replicated user ID.
    Hence the output continues to come only for one particular user in all the systems.
    Kindly request to provide some inputs / suggestions at the earliest.
    Thanks and regards.

    Is aanyone able to help with this?
    Thanks

  • New iPad does not display sent messages

    i set up the mail, send mial happily. but when i go to sent mail folder, it displays sent e-mails form last year, and all the wya back to 2011, but not the ones i sent this week since getting the new iPad.  anybody have any ideas?

    The model number that you listed is a WiFi only iPad (original, not iPad 2) so it will not connect to 3G data as I think you already know. 
    Doesn't one have to have an AT&T account to connect to attwifi?  If they do have an AT&T account and are trying to connect do they ever get to a logon screen (best way to bring it up is to try and access any site over the web, you'll get redirected to a sign-in page).
    Other question is how strong is the signal, I have lots of issues with public WiFi being strong enough for my device to see it, but not strong enough to actually connect and do anything.

  • New Content Editor not displaying website with CSS

    I am sure I am doing something wrong, but I just am not sure where to start. I am able to edit my website under the old InContext editor and it displays just fine:
    However, when I try using the new Content Editor, this is what I see:
    What am I doing wrong? I am using dreamweaver to upload my site. I can't figure it out.

    It' a known issue, pages displayed in the new ICE fail to load relative resources.CSS, images, scripts.
    As an workaround: use paths relative to the site root to link to resources, always starting wth a slash /.
    For example:
    <link rel="stylesheet" href="/plugins/smallipop/css/contrib/animate.min.css" type="text/css" media="all" title="Screen" />
    Dan Popa

  • Opening new tab does not display my home page by default, what setting do I change to achieve this?

    When selecting the open new tab option, in the past, the tab opened displaying my designated home page. It now opens displaying a YAHOO! search page. My home page settings have not changed and continue to display the correct address, selecting 'home' brings up the correct home page, at any time during browsing. Is there another location where this 'invalid' new tab address might be listed, and removed or reset ?

    VC you are a genius! I solved my problem with your solution.
    Thanks a lot!

  • Help - new iMac 5k not displaying retina resolution after migration from older iMac?

    Hello all,
    I have just recently purchased and started up a new iMac 27" 5K iMac.  Upon startup I took a look at the display settings to play with the different options for optimizing screen real estate.  I noticed that the default setting for the new iMac is labeled as "default retina" and when you mouse over this setting a line appears that says "looks like 5120 x 2880".
    An hour later I migrated my files and settings over from my previous iMac (27" late 2012) but noticed that when I go into display preferences it no longer has exactly the same options.  Now the default setting is simply listed as "default" (not "default retina" as before the migration) and the line that appears states "looks like 2560 x 1440", which was the resolution of the older iMac.
    I am unable to figure out how to revert back to the retina display options.
    Has this happened to anyone else?  Your help is much appreciated.
    Thanks,
    Warren

    The warranty entitles you to complimentary phone support for the first 90 days of ownership.
    If you bought the product in the U.S. directly from Apple (not from a reseller), you have 14 days from the date of delivery in which to exchange or return it for a refund. In other countries, the return policy may be different. If you bought from a reseller, its return policy applies.

Maybe you are looking for