Dynamic JTree; updating the Jtree during app execution

I have a JTree that renders a DOM Tree. All is well. I can set different icons in the tree depending on the type of node. The functionality I need is to dynamically change the icon in the JTree for a given node. I have a wrapper object that extends DefaultMutableTreeNode and contains an Icon member varrialbe. The problem is that this varriable is initialized by a custom TreeCellRenderer depending on the contents of the node.
I have also tried having a node_status flag inside my wrapper node, to give the Cell Renderer something to check to determine what to make the icon. The problem, I think, is that the JTree gets rerendered everytime an AWT event is fired; rerendering the JTree causes my wrapper nodes to be reinstanticated thus clearing all information in the Node, including the node_status flag.
Has anyone done anything similar, or does anyone have any insight into what is going on?
thanks.
-karl

I have figured out my problem and am posting it in the hopes that it helps others.
I created a custom TreeModel to deal with taking an XML (DOM) Tree and rendering it in a JTree. The problem comes from the custom class that I created to wrap the DOM nodes. The geometry for the DOM tree is contained in the DOM Node (getChild(x), an XML Tree is really just a single node with children, etc) and the problem stems from the wrapper object not knowing about the geometry of the tree except by traversing the tree through the DOM Nodes; since the DOM Node is a member of the wrapper node, traversal through the DOM tree breaks any data stored in the wrapper node which is reinitialized whenever you try to get a node's child.
Solution:
Do not render the tree recursivly with the DOM Nodes: render the tree itteratively with wrapper nodes. Because of the frequency the JTree gets redrawn, and thus the TreeModel gets hit with events, maintaining a semi-static tree will keep the information in the nodes.
-Karl

Similar Messages

  • I am trying to update the eBay Mobile app but it keeps saying This app requires iOs5. I have a 3G How can I get iOS 5.

    I am trying to update the eBay Mobile app but it keeps saying This app requires iOs5. I have a 3G How can I get iOS 5.

    You cannot.
    iphone 3g can only go to 4.2.1
    The iphone 3g was released 5 years ago.  This is very old in tech terms.

  • HT1904 When I try to update the Star Walk app I get a message requiring acceptance of new terms and conditions.  It never stops.  I accept even email myself a copy but I keep getting the same message.  How do I get past the message?

    When I try to update the Star Walk app I get a message requiring acceptance of new terms and conditions.  It never stops.  I accept even email myself a copy but I keep getting the same message.  How do I get past the message?

    The issue should be fixed now. Sorry about that, another Apple snafu but at least a short one.

  • I recently updated the Bible Gateway app

    I recently updated the Bible Gateway app & it won't open.  I deleted it & downloaded again but still won't open.

    Try a reset.
    Reset: Hold the Sleep/Wake and Home buttons and don’t let go until the screen goes dark and the Apple logo appears (no data will be lost)

  • Can't update the latest CC app (April 2015 - Photoshop CC2014 & BridgeCC)

    Hi,
    I use Macbook with latest OS updated.
    I can't update the latest app (April 2015 - Photoshop CC2014 & BridgeCC).
    Every time i've tried, the error occurred as you can see images attached.
    I've also tried uninstall and reinstall both apps, but same problem persists.
    It's few days since these updates show up, but until now I still can't update.
    Thanks.

    first, sign out and then back in to your cc app and retry updating, http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    if that fails, close your cc app and then reopen and retry updating.
    if that fails, restart your computer, sign out and then back in and update.
    if that fails,
    Remove the OPM.db file and relogin into the Creative Cloud desktop application using the Adobe ID tied to your subscription.
        Mac OS: You can locate the OPM.db file in the \User\<user name>\Library\Application Support\Adobe\OOBE folder. To access the hidden user Library folder, see Access hidden user library files | Mac OS 10.7 Lion.
        Windows: You can locate the OPM.db file in the \Users\<user name>\AppData\Local\Adobe\OOBE folder.  To view the hidden AppData folder, see Show hidden files, folders, filename extensions | Windows XP, Vista, Windows 7.

  • I am having problems updating the VZ Navigator App.

    I keep getting error messages 941 of 923.  Does anyone know what these error numbers mean?

    Try clearing cache and data in the Play Store app. Menu -> Settings -> Applications -> All
    If that does not work uninstall the Play Store update and try to update again.

  • HT4623 I have a 2nd generation i phone and I couldnt update the ' what's app ' because it didnt work with my latest software available for my phone ! What shall I do ?

    I have an i phone 3G 2nd generation and i can't update the 'whats app' because it requires iOS 4.3.1 software which is not available for my phone ! Also I have deleted the 'what's app' to reinstall it and now its not possible so what shall I do ?

    2 things:
    1. Talk to whatsapp developer for a version that can run on iOS 4.2.1 (your iPhone 3G latest and greatest iOS version)
    2. Buy a new iPhone.

  • Server down after updating the Blackberry World App Store

    Hi there,
    hopefully u can help me. For two days, after upgrating the Blackberry World App  i'm not able to acces the following:
    - internet
    - no more push up emails
    - BBM, Whatsapp, Windowslive Messenger, Facebook
    - email settings ( is giving me the following error " Your device had a problem connecting to the server"
    While i was upgrading the latest version of Blackberry World Application, was wasking me to update my Blackberry ID so i did it and after that all the problems came up. Looks like my blackberry server is down, can't acces anything. I contacted the carrier , they checked and said is it from aplication i have updated. They suggested me to delete the application which gives the problem. I deleted the files of Blackberry World App , but still the module is it in my mobile and can't be acces even when i tried to reinstall it.
    I don't know if this can help, but i have noticed that BIS is like disconnected while EDGE signal is there. Sometimes "EDGE" changes into "edges" ( small letters ) and GSM.  
    The carrier sent me again the service books, but i still have troubles ... nothing at all changed !
    The following Services Status is there:
    Connection : Mobile Network
    Balckberry Internet Service
    Connection: not connected
    Blackberry Enterprise Server
    Connection: not connected
    Mobile Netwok: 
    edge
    Mobile Network Provider
    orange
     I can't figure out what can cause this problem. Any help will be much appreciated.
    Thank u 

    Its clearly the ios 6 update...I have a 2 month old 4s...worked perfectly until the upgrade...now my app store rarely opens...other apps crash or will not load..battery life is now weak weak weak..
    The thing that TRULY amazes me is that I was on the phone with an apple tech yesterday,actually 2 different techs, when I said that there are several users on this site with the same problem their response was "first Ive heard of it !"
    Useless useless....

  • Migrated to a new mac pro and keep getting an install error when trying to update the creative cloud app

    I get an error when I try to start creative cloud that asks me to update. I download the updated installer and run it. I then get an error that says:
    Adobe Creative Cloud is needed to resolve this problem. However, it is missing or damaged. Please download and install a new copy of Creative Cloud from 'http://www.adobe.com/go/adobecreativecloudapp'.
    Following the message is two buttons. Quit and Get Creative Cloud. If I follow these directions I will sit here all day just downloading and trying to install Creative Cloud only to find out that I have a problem for which I need to download and install Creative Cloud. This would be like the person who uses a whole bottle of shampoo every time they get in the shower just because is says lather rinse repeat. Can you break this endless loop for me?

    Ado Bee in the future please only migrate documents and settings.  Adobe applications are not designed to be copied from one computer to another.
    You may still be able to recover by completing the following steps:
    Run all available uninstallers in the Applications/Utilities/Adobe Installers folder
    Run the CC Cleaner Tool - Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6 - http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html
    Reinstall the Adobe Creative applications included with your membership - Install and update apps - https://helpx.adobe.com/creative-cloud/help/install-apps.html

  • I updated the Muse CC App and it was subsequently deleted from my computer. Aside from this, I'm noticing that Muse crashes when performing very basic tasks. Will this be improved?

    HAS ANYBODY ELSE EXPERIENCED THIS?

    There was a bug related to the font submenus that many people encountered. (It could result in a crash up to a few seconds after having used the font menu.)
    An update went live yesterday that addresses it, and a number of other issues. Please go to the Creative Cloud Desktop App and download the update. Thanks.

  • Will they ever update the keynote remote app?

    I've been waiting litterly years for an update and I'm very eager to find out if they have an update in the pipes....

    have an updated app thats more than a glorified arrow key.
    Actually that is all it was designed to be, an iOS version of a hardware remote control; forward, back, and blank.
    I use Rowmote, it controls Keynote perfectly and adjusts sound, remote keyboard, appliation switching and can be set up to control many other applications.
    Rowmote Pro

  • Updated the adobe reader app and can't access my documents after resetting email & password on iPad

    What do I do now? I want to get to my documents.

    I was in the process of moving my PDF documents on my iPad to the cloud. Before the update, I just tapped on the cloud icon while I was in the document and the document was automatically sent. Now I'm asked for my Adobe ID and a password. When I enter that info it says my password or ID is incorrect. Adobe still showed my old email, and trying to do a reset was futile since I couldn't access an email that was sent to my old email address. I set up a new account and password. I still can't send a document to the cloud and can't get to the documents I had already transferred there. It keeps saying password or ID is incorrect.

  • Updating a JTree without application restart

    I would like to update the JTree in my application without restarting the application. The JTree elements come from a file, therefore, I update the file and want the JTree to be refreshed! I understand that this is done with swing and model and already do so eg: I update combo boxes and these automatically reflect the changes. I use the code below to update the boxes:-
    public void updateBoxes()
    DefaultComboBoxModel newComboModel = new DefaultComboBoxModel(getItems());
    myBox.setModel(newComboModel);
    I would basically like to do exactly the same using another model for a JTree.  Is this possible?  Also, as the JTree has actually been added to a scroll panel, so does this affect things?  Hopefully I can use a simple method like the one provided above for updaing a combo box.
    Thanks for any assistance

    * TestTree.java
    package com.test;
    import javax.swing.tree.DefaultMutableTreeNode;
    public class TestTree extends javax.swing.JFrame {
        private javax.swing.JScrollPane mainScrollPane;
        private javax.swing.JButton btnChooseThree;
        private javax.swing.JTree mainTree;
        private javax.swing.JButton btnChooseOne;
        private javax.swing.JPanel buttonPanel;
        private javax.swing.JButton btnChooseTwo;
        public TestTree() {
            java.awt.GridBagConstraints gridBagConstraints;
            mainScrollPane = new javax.swing.JScrollPane();
            mainTree = new javax.swing.JTree();
            buttonPanel = new javax.swing.JPanel();
            btnChooseOne = new javax.swing.JButton();
            btnChooseTwo = new javax.swing.JButton();
            btnChooseThree = new javax.swing.JButton();
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            mainScrollPane.setViewportView(mainTree);
            getContentPane().add(mainScrollPane, java.awt.BorderLayout.CENTER);
            buttonPanel.setLayout(new java.awt.GridBagLayout());
            btnChooseOne.setText("One");
            btnChooseOne.setMaximumSize(new java.awt.Dimension(70, 27));
            btnChooseOne.setMinimumSize(new java.awt.Dimension(70, 27));
            btnChooseOne.setPreferredSize(new java.awt.Dimension(70, 27));
            btnChooseOne.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnChooseOneActionPerformed(evt);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
            buttonPanel.add(btnChooseOne, gridBagConstraints);
            btnChooseTwo.setText("Two");
            btnChooseTwo.setMaximumSize(new java.awt.Dimension(70, 27));
            btnChooseTwo.setMinimumSize(new java.awt.Dimension(70, 27));
            btnChooseTwo.setPreferredSize(new java.awt.Dimension(70, 27));
            btnChooseTwo.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnChooseTwoActionPerformed(evt);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
            buttonPanel.add(btnChooseTwo, gridBagConstraints);
            btnChooseThree.setText("Three");
            btnChooseThree.setMaximumSize(new java.awt.Dimension(70, 27));
            btnChooseThree.setMinimumSize(new java.awt.Dimension(70, 27));
            btnChooseThree.setPreferredSize(new java.awt.Dimension(70, 27));
            btnChooseThree.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnChooseThreeActionPerformed(evt);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
            buttonPanel.add(btnChooseThree, gridBagConstraints);
            getContentPane().add(buttonPanel, java.awt.BorderLayout.NORTH);
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Three");
            rootNode.add(new DefaultMutableTreeNode("One"));
            rootNode.add(new DefaultMutableTreeNode("Two"));
            rootNode.add(new DefaultMutableTreeNode("Three"));
            mainTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode));
            pack();
        private void btnChooseThreeActionPerformed(java.awt.event.ActionEvent evt) {
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Three");
            rootNode.add(new DefaultMutableTreeNode("One"));
            rootNode.add(new DefaultMutableTreeNode("Two"));
            rootNode.add(new DefaultMutableTreeNode("Three"));
            mainTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode));
        private void btnChooseTwoActionPerformed(java.awt.event.ActionEvent evt) {
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Two");
            DefaultMutableTreeNode subNode;
            subNode = new DefaultMutableTreeNode("One");
            subNode.add(new DefaultMutableTreeNode("Sub One"));
            subNode.add(new DefaultMutableTreeNode("Sub Two"));
            subNode.add(new DefaultMutableTreeNode("Sub Three"));
            rootNode.add(subNode);
            subNode = new DefaultMutableTreeNode("Two");
            subNode.add(new DefaultMutableTreeNode("Sub One"));
            subNode.add(new DefaultMutableTreeNode("Sub Two"));
            subNode.add(new DefaultMutableTreeNode("Sub Three"));
            rootNode.add(subNode);
            subNode = new DefaultMutableTreeNode("Three");
            subNode.add(new DefaultMutableTreeNode("Sub One"));
            subNode.add(new DefaultMutableTreeNode("Sub Two"));
            subNode.add(new DefaultMutableTreeNode("Sub Three"));
            rootNode.add(subNode);
            mainTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode));
        private void btnChooseOneActionPerformed(java.awt.event.ActionEvent evt) {
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("One");
            DefaultMutableTreeNode subNode;
            DefaultMutableTreeNode subSubNode;
            subNode = new DefaultMutableTreeNode("One");
            subSubNode = new DefaultMutableTreeNode("Sub One");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub A"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub B"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub C"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Two");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 1"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 2"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 3"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Three");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub X"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Y"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Z"));
            subNode.add(subSubNode);
            rootNode.add(subNode);
            subNode = new DefaultMutableTreeNode("Two");
            subSubNode = new DefaultMutableTreeNode("Sub One");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub A"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub B"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub C"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Two");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 1"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 2"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 3"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Three");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub X"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Y"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Z"));
            subNode.add(subSubNode);
            rootNode.add(subNode);
            subNode = new DefaultMutableTreeNode("Three");
            subSubNode = new DefaultMutableTreeNode("Sub One");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub A"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub B"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub C"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Two");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 1"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 2"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 3"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Three");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub X"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Y"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Z"));
            subNode.add(subSubNode);
            rootNode.add(subNode);
            mainTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode));
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
        public static void main(String args[]) {
            new TestTree().show();
    }

  • Update a JTree from a file

    Hello everyone i have a wee bit of a problem here i have a JTree that gets updated by a text file. That bit works grand when the JTree is loaded it reads the text file and displays the contents now the bother i am having is the user has the option to add a new item to the text file but i cannot not seem to get it to update the JTree. I got to a point where it displayed the old and the new data in the tree is there a way to delete the old stuff

    I think you need to rebuild the entire tree each time there is a change. This way, you are certain that all the items that are removed from the textfile are also removed from the tree.
    Unless off course the text file is edited through the same application that displayes the tree, then you can come up with something smarter then that...
    Mark

  • JTree Update Leaf Icon

    Hi,
    I have two problem with Jtree.
    1.How can I put different Icons for different leafs of the same node?
    2.How is it possible to refresh or update the Jtree(by adding or removing some leaf) that the leaf Icons remain?
    Thanks for your help.

    1.How can I put different Icons for different leafs of the same node?Yes, ... either write a custom cell renderer or find a "merged icon".. there are examples of both around the forums.
    2.How is it possible to refresh or update the Jtree(by adding or removing
    some leaf) that the leaf Icons remain?No. if you remove a node, the node is gone. If you don't remove the node, the node stays. IF you want to leave the leaf icon, you can have a renderer which just displays the icon and not the text.

Maybe you are looking for

  • Apple Mobile Device Is Not Started

    OK so updating Itunes to 10 has caused me a whole slew of problems. First there was the issue of it recognizing it as a camera which I never got that part fixed cause when I tried to update the driver as instructed, it told me it was already up to da

  • Slide show - how to fill page

    Hi guys, please may someone explain to me how I fill a page and browser with a slide show? Can I edit the pre-set ones in Muse already available or do I have to create one in Edge Animate please?  I am wanting to literally have an image cover the ent

  • I recently Upgarded to Mountain Lion and Now my Safari won't load

    Here's my crash report. Process:    Safari [770] Path:        /Applications/Safari.app/Contents/MacOS/Safari Identifier:  com.apple.Safari Version:    5.1.6 (7534.56.5) Build Info:  WebBrowser-7534056005000000~6 Code Type:  X86-64 (Native) Parent Pro

  • Embed flash files

    Is there an easy way to get rid of the activate contol in windows xp internet explorer? The new ie update now asks the user to click to activate contol. I embeded flash into alot of sites and I do not want to add javascript manaually to each page. d

  • Running specific VM on Windows - dll collision?

    I've got an app install that bundles the Java VM and my app's JAR. I've created an .exe that launches the VM with the JAR in the path. This works fine when no other VMs are running on the machine. However, if there are other VMs running, the app exhi