Dynamically changing the color of nodes in a JTree

I have created a JTree and want to dynamically change the color of some of the TreeNodes as my program runs. The JTree is displayed in a JPanel. There is an algorithm built into which identifies the nodes whose color I need to change. No user actions is performed (everythign is internal to the program).
It seems that in the TreeCellRender only kicks in when the tree is first displayed. How do I get it to re-render the tree when the TreeModel changes? It seems that the Listeners are only looking for external user interactions.
Any help would be greatly appreciated.
Thanks!

I think I was a bit too vague in my question. Let me try again...
I have changed an attribute in a node in a JTree. This attribute is changed after the tree was initially rendered, but while the program is still running. I want to tell the TreeCellRenderer to look again at this node since that attribute that was changed will effect how the node should be renderered. I tried using the nodeChanged() method, but it did not work (the colot of the node did not change). Any advise how I can do this?
Thanks!

Similar Messages

  • Changing the color property node of an indicator based on a certain condition

    An upper level VI sends a set of conditions to a VI that SHOULD change the color of the indicators based on a set of t/f cases. However, the color of the indicators is changing in the lower level VI but not in the VI that is doing the calling. I am not using an while loops, just case statements. Help?!
    Attachments:
    status_reponse_coloring.vi ‏240 KB
    upper_level.vi ‏33 KB

    What you need to do is get a reference to the upper level VI control that you want to change to colour of. I have edited your VIs that you included to show how I passed the references to the controls into the subVI. The subVI can then change the colours, values, labels, etc. of the controls and changes are immediate.
    Hope this is what you're looking for.
    Rob
    Attachments:
    upper_level.vi ‏24 KB
    status_reponse_coloring.vi ‏247 KB

  • Dynamically setting the color of the title in a Panel

    Hello, I know I can set the color & font of the title in a Panel using the titleStyleName in a stylesheet.  How can I dynamically change the color though?  I have a component:
             <mx:Panel id="myPanel"borderColor="{this.color1}" />
    where this.color1 is a value that changes dynamically, and thus changes the border color.  How do I do this for the color of the text in the title?

    Hi,
    Try this
    var css:CSSStyleDeclaration = StyleManager.getStyleDeclaration(".myPanelTitle");
    css.setStyle("color",0x00FF00);

  • Help Needed : Changing the Color of Bar Graph Dynamically

    Hi..
    Is der any body to help me out...?
    My Question is :- How to change the color of Bar graph Dynamically..
    For example (Assume when one of the Bar Graph crosses certain limit of Y axis value mentioned, the graph must be changed into RED color)
    Thanks in Advance
    Edited by: user12873839 on Mar 30, 2010 10:03 PM

    Manoj,
    You have to create the entire chart manually. follow the below steps. You can refer to the anychart website for more help on different tags and features.
    1. Enter the following code in the html header of the page
    <script src="#WORKSPACE_IMAGES#AnyChart.js"  type="text/javascript" > </script>2. Create an ON Demand Application process by going to the Home>Application Builder>Application #>Shared Components>Application Processes
    3. Click On Create
    4. Enter the name as DYNAMIC_BAR_GRAPH_CHART
    5. Select the processing point as On Demand
    6. Click on Nxt
    7. Enter the following code in the processing text
    DECLARE
    BEGIN
    OWA_UTIL.mime_header ('text/xml', FALSE);
    OWA_UTIL.http_header_close;
    HTP.p ('<?xml version = "1.0" encoding="utf-8" standalone = "yes"?>');
    HTP.p ('<anychart>');
         HTP.p ('<settings>');
              HTP.p ('<animation enabled="True"/>');
         HTP.p ('</settings>');
      HTP.p ('<charts>');
       HTP.p ('<chart plot_type="CategorizedVertical">');
         HTP.p ('<data_plot_settings default_series_type="Bar">');
              HTP.p ('<bar_series>');
                        HTP.p ('<tooltip_settings enabled="True">');
                        HTP.p ('<position valign="Top" halign="Right"/>');
                        HTP.p ('<format> Name: {%Name}');
                        HTP.p ( 'Value : ${%YValue}{numDecimals:0}');
                        HTP.p ('</format>');
                        HTP.p ('<font bold="false"/>'); 
                        HTP.p ('<background>');
                        HTP.p ('<corners type="Rounded" all="3"/>');
                        HTP.p ('<border type="Solid" color="DarkColor(%Color)" thickness="2"/>');
                        HTP.p ('</background>');
                   HTP.p ('</tooltip_settings>');
              HTP.p ('</bar_series>');
         HTP.p ('</data_plot_settings>');
         HTP.p ('<data>');
              HTP.p ('<series name="series 1">');
               FOR cThis IN (select table2.name, table2.value
                                  from table1,table2,table3
                                  where table1.T1ID = table3.T3ID
                                  and table2.T3ID = table3.T3ID
                                  and table3.C_ID=1
                                  and table3.A_ID=1
                        ORDER BY table2.name )
              LOOP
                   IF cThis.value > 90 THEN
                        HTP.p ('<point name="' || cThis.name || '" y="'|| cThis.value || '" color="red"/>');
                    ELSE
                        HTP.p ('<point name="' || cThis.name || '" y="'|| cThis.value || '" />');
                   END IF;
              END LOOP;
              HTP.p ('</series>');
         HTP.p ('</data>');
         HTP.p ('<chart_settings>');
              HTP.p ('<title>');
                   HTP.p ('<text>Chart Title</text>');
              HTP.p ('</title>');
              HTP.p ('<axes>');
                   HTP.p ('<y_axis>');
                        HTP.p ('<title>');
                             HTP.p ('<text>Value</text> ');
                        HTP.p ('</title>');
                        HTP.p ('<labels>');
                             HTP.p ('<format>${%Value}{numDecimals:0}</format>');
                        HTP.p ('</labels>');
                   HTP.p ('<axis_markers>');
                   HTP.p ('</axis_markers>');
                   HTP.p ('</y_axis>');
                   HTP.p ('<x_axis position="Normal" align="inside">');
                   HTP.p ('<labels display_mode="Rotated" rotation="90" align="inside" />');
                   HTP.p ('<title>');
                        HTP.p ('<text>Name</text> ');
                   HTP.p ('</title>');
                   HTP.p ('</x_axis>');
              HTP.p (' </axes>');
         HTP.p ('</chart_settings>');
        HTP.p ('</chart>');
      HTP.p ('</charts>');
    HTP.p ('</anychart>');
    htmldb_application.g_unrecoverable_error := true;
    END;8. Click on Create Process
    Now we will create a html region to display the graph.
    9. Create a new region of type HTML on the same page and select the region template as no template.
    10. Enter the following code in the region source
    &lt;div id="DynamicaBarGraph"></div>
    &lt;script type="text/javascript" language="javascript">
    function DynamicaBarGraph()
    var DynamicaBarGraph = new AnyChart('/i/flashchart/swf/AnyChart.swf');
    //    DynamicaBarGraph.width = "400";
    //    DynamicaBarGraph.height = "400";
    DynamicaBarGraph.addEventListener('pointClick', onDynamicaBarGraphClick);
        var DynamicaBarGraphData = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=DYNAMIC_BAR_GRAPH_CHART',0);
        gReturn = DynamicaBarGraphData.get();
        DynamicaBarGraph.setData(gReturn);
        DynamicaBarGraph.write("DynamicaBarGraph");
    function onDynamicaBarGraphClick(e)
    // Read point name
         name=e.data.Name;
    // Read point value
         value=e.data.YValue;
    // You can add onclick even here using the values name and value
    DynamicaBarGraph();
    </script> Hope it helps. Thanks.
    Regards,
    Manish

  • How can I change the color of plot in a waveform chart and graph?

    There are 4 plots in a waveform chart, from plot0 to plot3, and I want to chang the color of plots dynamicly up to my needs when the VI is running.
    For example, as show in the picture, i want to set the plot0 as RED, and plot1 is BLUE, plot2 is YELLOW, plot3 is GRAY.
    If there is only one plot, i can change it's color, however when there are more than one plot, it fail.
    How can I do it?
    Thanks
    Attachments:
    waveform.JPG ‏61 KB

    Hello MilkyStone,
    first you have to set the active plot, then change its color (or other properties). All that is done using property nodes.
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How can i dynamically vary the color of one graph line

    I was looking on the developer zone and noticed several people are looking for a way to change the color of one graph line. Simplest case I would like to know: a graph is running, then you press a button and from that point on the color of the graph changes, but doesnt change the old data line color. THis way the line will consist of different colors.
    The property node changes the whole line, and the line is always just one color. It should be possible to make the line consist of different color sections, anyone know how?

    The application is actually not as slow as it seemed, i had some settings set wrong (anti aliasing in plot, and some functions in advanced, when you right click on the graph)
    Especially unchecking the anti-aliasing makes it much faster
    Also, just plotting point and not a line, or alternatively, changing the interpolation makes it faster.
    Anyway, the attached files do not rely on processor so much anymore, see for yourself
    Attachments:
    multicolor_looking_plot.vi ‏99 KB
    multicolor_looking_plot_2.vi ‏105 KB
    multicolor_looking_plot_3_truncated_array.vi ‏99 KB

  • How Can I change the color in a 3d object?

    Hello.
    I have received a 3dPDF, on which several buildings are created in 3d. Is it possible afterwards to change the color of the buildings in Acrobat X Pro? Or do I need the plugin "Tetra4D"?
    Thank you for your help.
    Greeting
    Sascha

    You can change the color of model parts dynamically at runtime using JavaScript, but there is no way to change them within the embedded model itself.

  • How can i change the color of the graph in agreement of the program's condition

    Hi,
    I am using labview 5.1 in my graduation's project final. (sorry by my english, but i am ina hurry)
    How can i change the color of the graph in agreement of the program's condition?
    I am developing a VI to control the temperature of termistors,but i have another sensor too.
    In a graph i have the situation of the termistors,but i want to change the color of the graph when the sensor is active.
    Thanks a lot
    Rafael Wajnsztajn - Brasil

    To change the color of the line itself, you can use the attribute Plot>>Plot Color.
    To change the color of the points, you can use the attribute Cursor>>Cursor Color.
    To select the color, you should have a color box constant inside the Numeric>>Additional Numeric Constants palette.
    This is all in LV 7.0. I'm not sure how it similar it is in 5.1.
    One important thing is to place the attribute node inside a case structure which will execute only when your condition has been filled.
    If this didn't help you, I suggest you post the relevant piece of code, or at least an image of it (no BMPs, please).
    Try to take over the world!

  • Assets panel styles, can i change the color of a style to be an exact color?

    Assets panel > styles, can i change the color of a style
    to be an exact color? for example, if i want to create a navbar
    with the black and gray glass affect style, but i want to change
    the color but keep the same style of shading. each style in the
    assets panel has a default color, but i want to change the color
    and keep the style. i did change the color a little bit by
    adjusting the hue and saturation, but i can't seem to get an exact
    match of the color i am trying to duplicate. any help is greatly
    appreciated thanks

    When a style is applied to any object, the Properties panel
    at the bottom will reflect the attributes which are editable in
    that applied style. The properties which can be edited are fill and
    stroke colors also apart from adjusting the Hue and Saturation.
    Gradient colors can be modified by changing the fill color.
    The nodes in the gradient will change the color from blue to black
    or any other intended color of change. If you know the color you
    can either enter it as a 6 digit value or you can pick a color from
    an existing object.
    Hope it helps. Let me know I am missing you query
    completely.

  • How can i change the color of a blinking button?

    Dear all,
    how can i change the color of a blinking button with property nodes, when the button changes from "normal" state to blinking state? I can change the color of the normal state, but how can I change the color when the button is in blinking state?
    thanks

    jus an example
    Ian F
    Since LabVIEW 5.1... 7.1.1... 2009, 2010
    依恩与LabVIEW
    LVVILIB.blogspot.com
    Attachments:
    Blinking_Indicator_2003.vi ‏27 KB

  • Dynamically changing the name of the .dll file to load in call Library

    Our current model is to use dll files as "plug-in" modules for instruments and a top layer test step calls the appropriate driver dll.
    For instance
    the TestStep is called with the kenmore.dll passed as a parameter so the kenmore.dll file is loaded, the functions are registered and the functions are called.  Next the TestStep is called with whirlpool.dll as a parameter now the whirlpool.dll is loaded the functions are registered and the functions are called.  This works very well in our current CVI/LabWindows environment.  Now we plan to work with LabView, we wish to retain this model (as DLL files, there are advantages in our model for us).  We have not found a way to load these dll files from LabView without hard coding the path and filenames in.
    Any suggestions on how to dynamically change the path in the Call Library module, or another suggested method of loading the dll via LabView?
    Thanks,

    John Stuart wrote:
    Our current model is to
    use dll files as "plug-in" modules for instruments and a top layer test
    step calls the appropriate driver dll.
    For instance
    the TestStep is called with the kenmore.dll passed as
    a parameter so the kenmore.dll file is loaded, the functions are
    registered and the functions are called.  Next the TestStep is
    called with whirlpool.dll as a parameter now the whirlpool.dll is
    loaded the functions are registered and the functions are called. 
    This works very well in our current CVI/LabWindows environment. 
    Now we plan to work with LabView, we wish to retain this model (as DLL
    files, there are advantages in our model for us).  We have not
    found a way to load these dll files from LabView without hard coding
    the path and filenames in.
    Any suggestions on how to dynamically change the path in the Call
    Library module, or another suggested method of loading the dll via
    LabView?
    Thanks,
    As Ben has pointed out LabVIEW
    scripting may be a possibility but you are going with that in highly
    unsupported area. Also I happen to know that changing the library name
    of a Call Library Node through scripting has produced unsupported
    feature errors previous to LabVIEW 7.1 eventhough the method was there.
    And LabVIEW 8 hides the whole scripting business behind the license
    manager.
    Another approach at least if the different DLLs do not change to often
    thier functions and parameters would be to create a wrapper DLL. Have
    it a method that loads the desired DLL and links its functions to
    internal function pointers. Then when calling the actual function entry
    points just redirect directly to the correct fucntion through that
    function pointer. Since you are already working in CVI creating such a
    DLL should be only a matter of taking out a little bit of your already
    existing code and put it into a DLL project.
    Rolf Kalbermatter
    Message Edited by rolfk on 04-12-2006 07:40 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to change the color of the item in the tree.

    Hi
    I am using TREE for navigation and it has nodes. I would like to change the color of the node if it is clicked.
    Any ideas?

    Hi Denes,
    I had same query like I was looking for, how to highlight node
    which user has clicked ! I followed your stesp like :-
    select "emp" id,
    "mgr" pid,
    CASE
    WHEN PROJECT_NAME = :F200_USER_SELECTED
    THEN '<span class="HighlitTreeNode">'
    || PROJECT_NAME
    || ' '
    || '</span>'
    ELSE PROJECT_NAME
    END name,
    'f?p=&APP_ID.:16:&SESSION.::NO::F200_USER_SELECTED,F200_USER_SELECTED_TABLE_ID,F200_USER_SELECTED_TABLE_NAME:'||"LOB" ||','||"ID"||','||"TABLE_NAME" link,
    null a1,
    null a2
    from TREE_PROJECTS
    and set Stylesheet to :-
    <style>
    a {text-decoration:none;font-weight:bold;}
    a:hover {text-decoration: underline; color: darkred;
    font-weight:bold;}
    .HighlitTreeNode {font-size:12px;font-weight:bold;color: darkred;
    margin-left:20px;white-space:nowrap;}
    </style>
    ====================
    This has solved my query completely.
    Thanks a ton for such a nice tip !
    Regards,
    -DVS

  • Is there a way to change the colors of multiple VI front panels?

    Hi,
    I am currently creating a LabView program controlling a lot of sensors and actuators. I have based the GUI on a tab-control with different buttons which again opens up different VI front panels in a singel sub panel below. I realy want to have a different color theme on my program than the standard gray LabView theme, but I would like to change the colors for all my VIs in a smooth and quick way. I really would not like to click on all controls, indicators etc. to get new colors, as there are a lot of them! Any ideas out there, if this is possible?
    Thanks in advance!
    Lars

    Lars,
    please note that using the grayscale theme is recommended not only by NI. Using color is very delicate thing since you have to consider:
    - readability of text might suffer due to insufficient contrast
    - overuse of (signaling) color might distract the user from important settings/information
    - color-blind user?
    That being said, you can color the frontpanels of the VIs you include in the sub panel dynamically. Please take a look into attached example on how this could be done (LV 2009).
    Please note that this is recoloring the frontpanel background only. If you need other elements to recolor as well, this can be done similar but is more effort....
    hope this helps,
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.
    Attachments:
    FP ColorChange.vi ‏14 KB

  • Can I change the color properties of an indicator in a cluster?

    I have a cluster that has three boolean indicators in it. I would like to have an initial state (color) they are in at the beginning of my test. Is there a way to set color properties of a boolean indicator that is inside a cluster? Thanks in advance for any help.
    Troy
    Solved!
    Go to Solution.

    Hi Troy,
    I just created a simple application in which I can change the color of one of my boolean indicators on the fly. You'll find it attached to this message.
    It's quite simple to do:
    When you've created both clusters in the front panel, right click on the indicator you want to change the color of.
    Select the option "Create"
    And than select the option "Property Node"
    Now you can ad whatever property to the boolean indicator you want.
    Hope this will help you any further with your program!
    Best regards,
    Peter S
    Attachments:
    change boolean color in cluster.vi ‏9 KB

  • How to programatically (dynamically) change the chart legend ?

    How do I add new labels/symbols to the chart legend dynamically ?
    I'm creating a scatter graph using the query
    select A,B,C from tableX group by A
    B is the y-axis, C is the x-axis. Points plotted for each grouping of A will be a different color. I know I can change the color of the point to be plotted thru the format trigger. The format trigger will change the color of the plotted points when there is a change in the grouping of A. My problem is how can I add a new label/color to the legend for each grouping of A as it is plotted ? The number of groupings of A is variable depending on what's in tableX. I need to programatically create the legend (each grouping of A will have it's own label/color) thru the format trigger as I won't know before hand how many groupings of A there will be.

    Try with Presentation variables.

Maybe you are looking for