JTree Hide Show nodes

Hi All
I have a JTree, and would like to hide some tree nodes based on a certain path, i have been using the setFilter and I can't seem to get to work.
Regards
M
Code fragment below: using the FilterTreeModel
void cmdShowSubset_actionPerformed(ActionEvent e) {
DefaultMutableTreeNode tn = new DefaultMutableTreeNode(value);
FilterTreeModel ftm = new FilterTreeModel(tn);
ftm.setFilterNode(tn);
Object[] oArray = new Object[1];
oArray[0]="ABC communications";
tp = new TreePath(oArray);
subTree.setSelectionPath(tp);
class FilterTreeModel
extends javax.swing.tree.DefaultTreeModel {
DefaultMutableTreeNode filterNode;
public FilterTreeModel(DefaultMutableTreeNode root) {
super(root);
public int getChildCount(Object obj) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) obj;
if (filterNode != null && !filterNode.isNodeDescendant(node)) {
if (node.isNodeDescendant(filterNode))
return 1;
return 0;
return super.getChildCount(node);
public Object getChild(Object obj, int num) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) obj;
if (filterNode != null && !filterNode.isNodeDescendant(node)) {
if (node.isNodeDescendant(filterNode)) {
TreeNode temp = filterNode;
while (!node.isNodeChild(temp)) {
temp = temp.getParent();
return temp;
return null;
return super.getChild(node, num);
public void setFilterNode(DefaultMutableTreeNode node) {
filterNode = node;
DefaultMutableTreeNode root = (DefaultMutableTreeNode)super.getRoot();
super.fireTreeStructureChanged(root, super.getPathToRoot(root), null, null);

When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.

Similar Messages

  • Hide leaf nodes from jtree.

    Hi,
    How can I hide all nodes that are leafs on a tree? Basically, I'm creating a splitpane where on the left side I have a jtree where when a user clicks on a node on that jtree the leaf nodes will appear on the right split pane as icons.
    V

    Thanks for the reply...
    I wanted to include the leaf nodes in the tree model so that I won't need to work with two data structures--one with the leaf nodes, and another without the leaf nodes.
    So far, I think I resolved the problem. I created my own treemodel class where I pass a defaulttreemodel into it and created a modified getChildCount which will go into the defaulttreemodel and filter out the leaf nodes.
    It all seems to work pretty well.
    My problem now... How do I remove the stupid node icons? :)
    I just want the dashed lines to appear and nothing more....
    Thanks again...
    V

  • Reg. JTree - Make a node visible/invisible

    Hai,
    I want to design a JTree with say two nodes, both having some child nodes. At any point of time, I want to display only one of these child nodes. Is there any way to set this property for the JTree.
    Thanks in Advance,
    Bala.

    You have to make a custom tree model that shows/hides the nodes. Look at the javax.swing.tree package for details.

  • Hide / show grid in a graph programmaticly

    I would like to hide / show the grid (minor / major) progammaticly. I try to create a property node, but I don't find the way to access the 'hide' property... Thanks.

    I might need corrected, but I don't believe you can change the 'minor' grid color, but yes on the 'major'.
    Its a Write-to property node called Grid colors, and you can have the X & Y grids as separate or Clustered together elements. You'll need to add 2 color boxes [Controls > Numeric palette] to your front panel (X & Y). The user's selection is a numeric value sent to the property node(s) you wired.
    Good Luck with it, Doug

  • JTree hide Path

    Hello,
    I am using jTree to show folder named c:\Test, It has many directories & subdirectories. I would like to hide path & only name to be displayed.
    C:\Test
    c:\Test\folder1
    c:\Test\folder2
    c:\Test\Folder3.
    c:\Test\Folder3\Folder31
    I need display like this:
    Test
    Folder1
    Folder2
    Folder3
    Folder31
    How to do that??? Any Ideas.
    Thanks

    Note: This thread was originally posted in the [New To Java|http://forums.sun.com/forum.jspa?forumID=54] forum, but moved to this forum for closer topic alignment.

  • Problem in Hide/Show in a Table Row

    Hi,
    i have to create 4 pages and each page has a table region with displaying records and a column "LINK" to go to the next page with the parameters from that record. Every link has a batchId and one another Id as parameter to next page. The next page reads the parameters and queries the corresponding table for details of that results table region contained in that page.
    Thus i have 4 pages with 4 table regions and each table region is associated with a view object which is based on an EO connected with a database table. (4 VO's).
    Now in every table i have a detail region (hide/show) which shows error records for a row ....
    thus there are 4 ViewLinks for all 4 VO to a single ERROR VO.
    I have 4 instances of ERRORVO in AM like ERRORVO1, ERRORVO2, ERRORVO3, ERRORVO4.
    Now, the hide/show region is working properly on the first 3 pages with proper navigation to pages.
    Then, i created the 4th page and created the table region in the 4th page.
    From the 3rd page i have passed 2 parameters through the link and also retainAM=Y.
    i have captured both parametres and call a method to populate data in table of 4th page.
    Successfully done..running properly....
    Now i added the detail region which is a table as previous pages in the 4th page with ERRORVO4...
    Then when i run the page i get the 1st page and thrugh link i move to 2nd and to 3rd page. But when i click on the link on 3rd page to move to 4th page i m getting "NullPointerException" with "check Inner table properties"
    Now i removed the detail region (Hide/show) only from the 4th page and again run the page . its working properly for all 4 pages with proper navigation but i am not able to see errors with hide/show on 4th page and it is required.
    i m not getting what could be the reason...
    do i need to remove retainAM=Y from the page navigation links.?????
    and is there anything like we cant create more no. of instances (4) of a single VO in an AM.....????
    Any alternative for showing the errors on 4th page with Hide/Show or without Hide/Show????

    Thiago,
    Thanks for the quick reply.
    I am now getting the following error below:
    Am I suppose to add another field to my VO select?
    oracle.apps.fnd.framework.OAException: Detail View Attribute Name is not set for the table even though a detail named child has been specified. Please specify a Boolean or String ("Y" or "N") view attribute for this table property.
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1146)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1794)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:463)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:384)
         at OA.jspService(OA.jsp:40)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:139)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)

  • How to hide/show and move screenelements at runtime

    Hi Guys
        Currently, i have a requirment that, in the same screen, when user choose different different option in the dropdown list, there should be different screenelements and table control with different columns showing below it.
    Now, i have two plans below:
    1), hide/show and move position of screen elements and table control at runtime
    2), call different subscreen
    I hope i can take the first way since the second way will modify structure of program ( As it is infotype screen ), any one knows how to implement the first solution?

    Hi,
    I would suggest you to call different subscreens and load them dynamically based on your parameters.Since different subscreen are called your coding and functionality could also be seperated by writing in the PAI and PBO of the correspondiong Screens.
    if you have decided to go by your first method then try the below code.
    a) if it is normal UI elements like text box etc
    LOOP AT SCREEN.
        IF <var> = ' value '.
            screen-invisible = '0'.
            MODIFY SCREEN.
      endif
    ENDLOOP.
    Here <var> refers to the screen field name and value refers to its value.
    b) To hide columns in a Table control.
    DATA cols LIKE LINE OF tc-cols.
      LOOP AT tc-cols INTO cols.
        IF cols-screen-group1 = 'G1'.
          cols-invisible = 'X'. "HIDE THIS COLUMN
          MODIFY tc-cols
          FROM cols
          TRANSPORTING invisible.
        ENDIF.
        CLEAR cols.
      ENDLOOP.
    PS: here TC refers to the name of the table control.
    Lemme know if you face any problems.
    Cheers,
    RK

  • SharePoint 2013: Hide/Show Column fields while uploading document in Document Library

    Dear all,
    I have created a document Library LIB001 and I have created One Column of type Choice, drop down list, (CCHOICE) and I have created 3 other columns, (Column1, Column2, Column3).
    What I want is while uploading a file in the document library, when I choose a certain value from CCHOICE, i want to show/hide and/or make the column mandatory.
    Can anyone help/guide me how to achieve this?
    Many Thanks
    Vinay

    Dear all, I am trying the following code, but it's not entering the onchange of drop down list event. <script> $(document).ready(function () { var countryField = SPUtility.GetSPField('Document Type'); var countryFieldValue = countryField.GetValue(); alert
    (countryFieldValue); // ----- Hide/Show the field based on new selected value. var id = SPUtility.GetSPField('Document Type').Dropdown.id; alert ('field ID: '+id); $('#' + id).on('change', function () { alert ('Inside on Change:'+countryFieldValue); if (countryFieldValue
    == 'Type1') { SPUtility.GetSPField('Column1').Hide(); } else if (countryFieldValue == 'Type2') { SPUtility.GetSPField('Column2').Hide(); } }); }); </script> Can anyone help me please. Many Thanks & Regards Vinay

  • Error while trying to search in advanced table with hide/show region

    Hi
    I have search region and a results table with a hide.show in it.I did a search initially and got the results.I clicked on the hide/show region to see the details.
    I put another search criteria in the search region and tried to do a search.
    I am getting the following error
    The search cannot be executed because the table has pending changes that would be lost...
    Can anybody help me on this please....
    Message was edited by:
    user580745

    Any setter/getter method being used on hide/show action? How are you enabling the details? Is there a transient column in your VO?
    --Shiv                                                                                                                                                                                                                                                                                       

  • Adding logic to the hide/show

    Hi Guys
    I am pretty new at this so please excuse my ignorance. I have added hide/show regions into a cell of an advanced table. In the VO I also coded in the boolean decode.
    So now when I run my page I get the the following: where there is details for the cell the cell is in Hide status, when the details are null its in show status.
    The decode is as follows: decode(contact_details.contact_name,Null,'0','1'). The attribute is set to Boolean.
    My issue is when I click on the hide/show link on the page it does not "work". ie: if I click on the show status it does not toggle to hide status and visa versa.
    Am I meant to add logic to the controller?
    Thanks

    Is your page embedded in a workflow page or notification? If so, then you cann't have hide/show action rather any action on your page as per workflow standards. They require you to embed a region and not a page.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Drill down hide/show report on same page

    Hi,
    Is it possible to create a drill down report where instead of linking to new pages, the details can be displayed using hide/show buttons on the relevant columns? For example, if you have the following fields:
    Region
    Country
    Division
    Account
    Order
    Product ID
    Product Price
    Would it be possible to ,by default, have the report only show distinct regions. By clicking an expand button on a particular region, it's countries are displayed. By clicking an expand button on a country, its divisions are displayed,etc., eventually being able to drill down to order details.
    This seems similar to a tree to me, although I have not used trees before. However, from the way I understand the structure of hierarchy in trees, the way this data is structured it would not be possible through a tree.
    Any ideas? If not I can just settle on a standard drill down report with links to new pages, but if the above is possible it would work much better for my users.
    Thanks

    FJW,
    Yes, it's possible. We typically refer people to this demo from Carl to get an idea of how it can be accomplished:
    http://htmldb.oracle.com/pls/otn/f?p=11933:13
    Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen

  • Trying to hide/show all series in legend with click on 'deselect' option.

    Hi Friends,
    I am trying to hide/show all series in legend with click on 'deselect' option. Please see the code below, let me what change i need to do:
    $(function () {
    $('#container').highcharts({
    chart: {
    type: 'line',
    marginRight: 130,
    marginBottom: 25
    title: {
    text: 'Monthly Average Temperature',
    x: -20 //center
    subtitle: {
    text: 'Source: WorldClimate.com',
    x: -20
    xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
    'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    yAxis: {
    title: {
    text: 'Temperature (°C)'
    plotLines: [{
    value: 0,
    width: 1,
    color: '#808080'
    tooltip: {
    valueSuffix: '°C'
    legend: {
    layout: 'vertical',
    align: 'right',
    verticalAlign: 'top',
    x: -10,
    y: 100,
    borderWidth: 0
                   plotOptions: {
    series: {
    events: {
    legendItemClick: function(event) {
    //var visibility = this.visible ? 'visible' : 'hidden';
    // (!confirm('The series is currently '+
    //visibility +'. Do you want to change that?')) {
    // alert ('other legend');
                                                                     if (this.name == 'Deselect')
    alert('hi');
    series.hide();
    //return false;
    series: [{
    name: 'Tokyo',
    data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
    name: 'New York',
    data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
    name: 'Berlin',
    data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
    name: 'London',
    data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
    name: 'Deselect',
    data: []
    Edited by: oracle_student_777 on Mar 27, 2013 10:05 PM
    Edited by: oracle_student_777 on Mar 28, 2013 4:08 AM
    Edited by: oracle_student_777 on Mar 28, 2013 8:59 PM
    Edited by: oracle_student_777 on Mar 28, 2013 11:15 PM

    More generally, Show All will only show when the Organizer isn't showing all your photos.  For example, if you click on a tag to show just the photos with that tag, the Show All button will show up.
    Alas, what I said above isn't completely true.   There are a number of situations where this rule doesn't hold:
    - When you've restricted the photos shown to a date range using Find > Set Date Range.
    - When you've restricted which media types to show using View > Media Types.
    - When you type text quickly into the search box and hit enter (on a large catalog).

  • How to hide a node with no children in ADF Tree after Search

    Hi,
    I have a tree component with Search in my screen.
    I followed http://www.jobinesh.com/2010/01/search-by-child-attributes-on-tree.html to implement search.
    Search is performing on the childnodes, once the search is done I am expanding all the nodes and displaying only the filtered records.
    my code to expand all the nodes :
    public void expandAllTreeNodes() {
    UIXTree tree = getGroupTree();
    RowKeySet disclosedRowKeys = new RowKeySetTreeImpl(true);
    CollectionModel model = (CollectionModel)tree.getValue();
    JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();
    JUCtrlHierNodeBinding nodeBinding = treeBinding.getRootNodeBinding();
    List<JUCtrlHierNodeBinding> childNodes = nodeBinding.getChildren();
    if (childNodes != null) {
    for (JUCtrlHierNodeBinding _node : childNodes) {
    disclosedRowKeys.add(_node.getKeyPath());
    disclosedRowKeys.remove(_node.getKeyPath());
    tree.setDisclosedRowKeys(disclosedRowKeys);
    Now I want to hide the nodes which does not have children after search.
    how can I hide the node if _node.getChildren() is null.
    Could any one provide some inputs on this.
    Thanks,
    Swathi

    AE Basics
    Keyframe the mask path.

  • Hide / Show region template - how to make it stay visible after NEXT& PREV?

    Hello,
    I am using the Hide / Show region template (by the way great idea to create this template ;)
    By default the region is hidden. If i want to see the region content (it is a report) I click on that icon and it becomes visible. For my report I use the pagination "ROW Ranges X to Y of Z (with pagination)".
    The issue is that if I click NEXT of Previous, the region is closing (hidding).. and in order to see the next / previous page of my report I have to re-open it..
    Is there any known workaround for this?
    Thank you in advance
    Anca

    I would start at Re: Toggle all hide show regions on a page open/closed
    It references the using javascript to manipulate your hide/show regions. It should get you started in the right direction. It is about the most straight-forward example I have seen for what you are trying to do<br><br>
    You could trigger the javascript after your page is rendered by calling it from the page footer and reference the values of page items to determine if you are supposed to hide the region(s).<br>
    Create a page item called P88_HIDESHOW_REGION1 and set it's value to Y or N depending on whether the #REQUEST# has a string in it that is part of report pagination. If you hover over a "next page" button in a report, check out the resulting URL that pops up in your browser.....it looks like ..../f?p=900:210:8352027355600111016:pg_R_241403738845262873:NO&pg_min_row=31&pg_max_rows=30&pg_rows_fetched=30
    <br>
    You could do an instr(:REQUEST,'pg_R_') > 0 then set P88_HIDESHOW_REGION1 = 'Y' else P88_HIDESHOW_REGION1 = 'N'. Your javascript called at the footer of the page could set the display of the region to on or off depending on the result of P88_HIDESHOW_REGION1

  • How to get Hide/Show using details in advanced table

    Hi,
    I develeoped one custom page using advanced table region and i used detail from advanced table for getting hide/show functionaliy in one column in that table. It is showing hide/show properly..but if I click on Show it is not doing any action..pls let me need to write any code in CO for getting action..
    Thanks in advance,
    Hanimi......

    If you are using the same VO and you execute in on page load then it must populate all view attribute.
    Check in back end that is there any data in that VO attribute exists or not.
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • IWork 09/Pages?

    When opening a word document downloaded from emails or the web, it opens in the expired "Trial Period" iWork 09 Pages app that came with the iMac (mid 2010 model) instead of the Pages stand alone app that I purchased through the App Store. How do I f

  • Accessing phone apps from laptop, accessing phone apps from laptop

    I use week cal rather thank the ical app on my phone. Can I add appointments to my calendar on this app via my computer? Will they stay synced?

  • Hp tools & Recovery Partition

    Hi  Ihave Notebook  g6  1048se with  (original win7 home)  I cant  creating New Simple volume  because There is already 4 partition ( C / D  recovery/ Hp tools / system). I making Recovery disk (4 DVD) . 1-     Is there any other way  to make new  pa

  • Dollar table droped in sys Schema

    hi , I am using oracle 11g database release 1,i dropped the dollar table in sys schema accidently is it possible to recover that table in SYS Schema. Any advice thank you

  • Query to find out 2 columns duplicate records

    hi how can i find out duplicate records from a table with 2columns duplicated eg: emp_id, book_id duplicated together emp_id book_id 001 A 001 A 001 B in this case query should return ( emp_id: 001 , book_id: A ) because these are duplicated together