JTree, branch expanding and TreeWillExpandEvent

You can expand a branch in JTree component either by double clicking the node's name or by single clicking the branch expanding icon (next to node icon). How can I determine which way was used when receiving the TreeWillExpandEvent ? It seem that it does not provide this information

It looks to me like TreeWillExpandEvent does not retain the mouse click information from the underlying event that caused the expansion. Looks like you would need to provide a custom UI and event mechanism to propagate that information.
Mitch Goldstein

Similar Messages

  • Changing JTree Expand And collapsed Icons

    Hi,
    can anyone tell me how to change the expanded and collpased icons on a JTree, i am using windows look and feel, and i don't know how to change the '+' and '-' icons, the other icons are changed using the DefaulTreeCellRenderer, but i haven't found a way to achieve my goal....
    thanks

    In the beginning of your main method you write :
    try {
         UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
         UIManager.put("Tree.collapsedIcon",new ImageIcon("plus.gif");
         UIManager.put("Tree.expandedIcon",new ImageIcon("minus.gif");
    catch (Exception exc) {
         System.err.println("Error loading L&F: " + exc);
    }And you change the name of the images with the wanted ones.
    Denis

  • Problem with JTree while expanding/collapsing a node

    Hi,
    I'm using a JTree for displaying the file system.
    Here, i want that whenever a node get expanded,
    it should show the latest files/directories under that node.
    Now, what i'm doing is, getting all the files/dir's using files.listFiles(),
    under that node and then creating a new node and adding it to parent (all in expand() method).
    But, now the problem is, while doing this whenever the parent node get expanded its adding all the latest files/dirs into the previous instance
    resulting the same file/dir is displaying twice,thrice.. and so on, as that node is expanded and collapsed.
    i tried removeAllChildren() in collapse() method but then that node is notexpanding at all .
    Can anybody help me please...
    i got stuck b'coz of this only.
    Thanks...

    Now what i'm doing is every time expand() get called,
    i'm comparing all the children of that node in the
    current instance with all the children present in the
    file system (because there is a possibility that some
    file/dir may be added or deleted)
    is this the right wy or not?it certainly is not wrong, but as usual, there is more than 1 way to implement this...
    b'coz right now i'm getting all the files/dirs that
    are newly added but facing some problem if somebody
    deletes a file/dir.
    i'm still trying to get the solutionthen you should not just compare all the children of the node with the files/dirs but also the other way round. compare the files/dirs with the children to determine if the file/dir still exists and if not remove the node.
    or you could check if the file which a node represents exists and if not remove the node.
    thomas

  • Making a node in JTree non expandable

    How do I make a node in a JTree non expandable. The nodes in the tree are DefaultMutableTreeNode. I have a tree with root R. It has children ch1, ch2, ch3. Nodes ch1 etc also have X number of children. What I want is if I click (either double click on the node or single clicking on the '+') on either of the child nodes ch1, ch2 and ch3 to disable expansion i.e. stop the tree collapsing beyond those nodes. I have tried tree.setExpandsSelectedPaths(false) and others but it still doesnt work. Any help much appreciated. Thanx.

    Thanx Jeanette, that is exactly!! what I'm looking for. Much appreciated.

  • JTree remove expand/collapse cross button...??

    Hi all,
    I have forbidden tree collapsing (by default it is fully expanded),
    and I want to remove expand/collapse cross buttons that actually are used to expand/collapse tree nodes.
    Is it possible and can anyone give me advice how i can do this.
    Thanks in advance.

    I tried extending the BasicTreeUI to return nulls for the collapsed and exapnded icons as shown in the code below. For the most part, it works great! However, one can still expand/collapse the tree by clicking on the point where the vertical and horizontal lines connect.
    I guess some one else will take over from here.
    import java.awt.BorderLayout;
    import javax.swing.Icon;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    import javax.swing.WindowConstants;
    import javax.swing.plaf.basic.BasicTreeUI;
    import javax.swing.tree.DefaultMutableTreeNode;
    public class Temp extends JFrame {
         private JTree tree = null;
         public Temp() {
              super("Test");
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              initComponents();
              pack();
              setVisible(true);
         private void initComponents() {
              DefaultMutableTreeNode rootNode =
                   new DefaultMutableTreeNode("User Preferences", true);
              DefaultMutableTreeNode connectionSettingsNode =
                   new DefaultMutableTreeNode("Connection Settings", true);
              DefaultMutableTreeNode sslNode =
                   new DefaultMutableTreeNode("SSL", false);
              DefaultMutableTreeNode firewallNode =
                   new DefaultMutableTreeNode("Firewall", false);
              DefaultMutableTreeNode securityNode =
                   new DefaultMutableTreeNode("Security", true);
              DefaultMutableTreeNode serverCertificatesNode =
                   new DefaultMutableTreeNode("Server Certificates", false);
              DefaultMutableTreeNode clientCertificatesNode =
                   new DefaultMutableTreeNode("Client Certificates", false);
              connectionSettingsNode.add(sslNode);
              connectionSettingsNode.add(firewallNode);
              securityNode.add(serverCertificatesNode);
              securityNode.add(clientCertificatesNode);
              rootNode.add(connectionSettingsNode);
              rootNode.add(securityNode);
              tree = new JTree(rootNode);
              JScrollPane scroller = new JScrollPane(tree);
              getContentPane().add(scroller, BorderLayout.CENTER);
              tree.setUI(new MyTreeUI());
              //tree.setShowsRootHandles(false);
         public static void main(String args []) {
              new Temp();
         class MyTreeUI extends BasicTreeUI {
              public Icon getCollapsedIcon() {
                   return null;
              public Icon getExpandedIcon() {
                   return null;
    }Sai Pullabhotla

  • JTree display issues and thread safety

    I've recently ran into some issues with a JTree not displaying correctly. Infrequently, blank space will appear in the tree (big gaps between consecutive nodes), or the text of a node will be cut off ending with a "...". This happens when (but not yet proven a direct result of) one thread is expanding a node of the tree while another thread is inserting nodes into one of the expanding node's children through calls to DefaultTreeModel.insertNodeInto. (what I'm doing here is lazy loading the children's children when the parent is expanded, and the lazy loading is performed by a seperate thread so as not to delay the main thread.) It does not happen if the second thread simply adds child nodes without using the DefaultTreeModel's insertNodeInto method.
    I think what might be happening here is that the DefaultTreeModel.insertNodeInto method is calling fireTreeNodesInserted which I think is in turn causing nodes in the tree to be re-rendered. This got me thinking that the problem may come down to the DefaultTreeCellRenderer being used by the two threads simultaneously. DefaultTreeCellRenderer extends JLabel and returns itself in the getTreeCellRendererComponent method. If two threads were causing nodes to be rendered at the same time, it would seem the rendered label could be occasionally in an inconsistent state.
    Anyone ran into a situation like this before? The problem of text being cut off seems to be eliminated by having a custom renderer return a new component each time, rather than returning itself, but this results in degraded performance. It's almost as if each thread would need it's own renderer (or the renderer would need to return a different component for each thread), but I'm not sure how this would be done. And this doesn't solve the problem of gaps appearing in the tree.
    As for the gaps, I think this might be solved by changing when the children's children are getting loaded in respect to the parent node expanding. At first I was using a TreeWillExpandListener that fired off loading the children's children. I think I might can solve the white space in the tree problem by changing that to a TreeExpansionListener that uses the treeExpanded method. So far this seems to be working...so that the parent node is done expanding before the second thread begins loading the children's children.
    Any thoughts?

    I actually found the thread3 article first... since there doesn't seem to be direct links between them, I thought I would add for anyone who reads this thread that there are several related articles. sabre150 linked the first; the others are the same base URL but with the number incremented for each. For example, the 2nd article is:
    [http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html]
    And the 3rd article, which most directly applies to what I am doing, is:
    [http://java.sun.com/products/jfc/tsc/articles/threads/threads3.html]
    Edited by: Skotty on Mar 5, 2009 9:35 PM -- links turned into actual links
    Edited by: Skotty on Mar 5, 2009 9:36 PM -- formatted for nicer display

  • JTree Button, Line and Java look and feel ?

    Hi all,
    I have 3 small problem with my JTree ..
    1) The 'expand' button size ...
    I set a different Icon for each node in a getTreeCellRendererComponent method (from a class that extends DefaultTreeCellRenderer )...
    The icon are 32x32 pixels.. .and the RowHeight and the Font have been changed too. .
    How to change the size of the expand button (+/-) near the text node ? Because on my JTree, the expand/collapse buttons are really small compare to the icon & row height.
    2) No line appear between the node ...
    I try to set the line style property with -> putClientProperty("JTree.lineStyle", "Angled"); in the JTree constructor OR in the DefaultTreeCellRenderer constructor .. but it doesn't work :/
    3) How to set a Java look and feel for my JTree (actually, I have a Windows look and feel ..)
    I know .. I have grouped 3 question in the same topic ...
    If anyone can help me on one of these subjects. .. Thanks !
    Regards,
    Didier

    So, the Problem 1) is solved ..
    About the Problem 2)
    I put the code UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel()) in the main method, like
      //Main method
      public static void main(String[] args) {
        try {
          UIManager.setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel());
        catch(Exception e) {
          e.printStackTrace();
        new MainApplication();
      }But it only set a Java L&F on the spliter, and on the toolbar contained in my application... Any idea why the title bar is not changed too ?
    (The title bar stay with a Window$ XP L&F ...)
    About the problem 3)
    When I set the L&F->UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); then the lines appear .. ??!! .. if I set again the previous value UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); .. then the lines desappear ..

  • Adding a link to expand and collapse all DHTML drop downs

    Hi, can anyone help me adapt the "Skinny on Skins" example "Add a Toolbar button to expand and collapse all DHTML drop downs" so that it will work with just a simple HTML link in RH8, instead of being attached to a custom skin button?
    The example looks like this:
    Step 1. Open the Skins Editor for the skin where you want to add the button.
    Step 2. After the preview loads into the window, ensure that the Toolbar tab has focus, then click the plus symbol. The Custom Toolbar Item dialog should display.
    Step 3. Type the Item Name (This is simply an internal reference for the button).
    Step 4. Type the Text (This is the text that will be seen by the end user. The field must contain something. So if you don't want any verbiage to display for your toolbar item, simply type a space.)
    Step 5. Choose your Image Options, then click the Action tab.
    Step 6. Click the JavaScript option button.
    Step 7. Enter the following code in the OnClick field:
    javascript:toggle()
    Step 8. In the JavaScript area, ensure the Inline JavaScript option button is selected, then click the edit (Pencil) icon located to the right.
    Step 9. Enter the following code in the Inline JavaScript dialog
    var show = "false";
    function toggle() {
    parent.frames[1].bsscright.focus();
    var arrayofDivs = parent.frames[1].bsscright.document.all.tags('DIV');
    if (show == "false") {
    for (x=0;x<arrayofDivs.length;x++) { arrayofDivs[x].style.display = "block";}
    show = "true";}
    else {
    for (x=0;x<arrayofDivs.length;x++) { arrayofDivs[x].style.display = "none"; }
    show = "false"; }
    Step 10. Click the OK button to close the Inline JavaScript dialog.
    Step 11. Click the OK button to close the Custom Toolbar Item dialog.
    Step 12. Click the OK button to close the Skin Editor.
    Step 13. Generate WebHelp via File > Generate > WebHelp and ensure that you have the new button selected with a check mark. This will probably require stepping through some screens to see the place where you can select it.
    Many thanks
    Jonathan

    Hi again
    I want to use it in the header of one of my Master Pages, so it will only be created/maintained once. Not all my pages have drop downs in so rather than have a toolbar button available for every page, I was trying to be a bit cuter by having two Master Pages - one for normal pages and one for pages with drop downs in.
    I'm no javascript expert so I'll see if one of my developers can help.
    Thanks anyway
    Jonathan

  • The bottom rubber case of my macbook 13" late 2009 has expanded and has detached from the main body..As i'm not presently under warrantty i wanted to know will the repair be free of charge for me. I had once got it replaced for free but in warranty.

    The bottom rubber case of my macbook 13" late 2009 has expanded and has detached from the main body..As i'm not presently under warranty i wanted to know will the repair be free of charge for me. I had once got it replaced for free but in warranty. As i read some where in the support that apple had agreed with the defect and had decided to replace the bottom covers without any charge. And even if i'm charged for it what will be the amount  will hav to pay for it..
    Thankx

    Hi,
    Here's the Bottom Case Replacement Link
    http://www.apple.com/support/macbook-bottomcase/
    It doesn't answer your specific questions about cost... but it does advise to contact an Apple Store or an AASP...
    Anyway have a look at it... if you haven't already..
    Cheers and Good Luck...

  • How to perform expand and collapse operation on click of link or button

    Hi
    Is there anyway by which i can perform expand and collapse operation over a table on click of a command link or button without using show details component.
    Is there any other alternative to show detail.
    I do not want to use show detail because of the following reason.
    I have got a page where in i pass some parameters to the URL based on which details get displayed on the page.
    Now when i pass a parameter, change the parameter, once again send the previously used parameter(i,e the parameter that i passed initially), values in the table under show detail do not show any change in values.
    Once i pass values which i have already passed, values in the table under show detail component do not refreshed.
    If anyone has encountered with similar situation, then please post me reply's as to how you could over come the problem??

    Hi
    Perhaps you could use an on-demand application process instead - you can specify these in the URL.
    The URL syntax (for your link) would be like...
    f?p=application_id:page_id:session:APPLICATION_PROCESS=process_idIs this what you mean?
    Cheers
    Ben

  • Expand and Collapse(+/-) option in a Matrix SQL Reporting Services 2008

    Hello All,
    I am having Expand and Collapse(+/-) option in a Matrix SQL Reporting Services 2008. It's not working when it is havnig a Row Group and Column Group.
    Does reporting services has this flexibulity?? It's working fine if it's only have a Row Group an it's not working if it is having Row and a Column Group. Can any one suggest how to work aroung with this.
    any help much appriciated.
    Thanks & Regards,
    Jeevan Dasari.
    Dasari

    Drill-down feature is a basic requirement, it is concluded in Reporting service from SSRS2000 to SSRS2008 R2, To
    your scenario I think the root cause is relevant to your incorrect steps. Please follow the steps below and then give the feedback:
    1.     Right-click the child groups in the
    Row Groups panel which is at the left-bottom of the BIDS, and then select
    Group Properties…
    2.   
    Switch to Visibility tab, and then select
    Hide Radio-button, click the checkbox of Display can be toggled by this report item.
    3.   
    Then select the parent group datafield in the drop-down list.
    4.   
    Click OK.
    Thanks,
    Challen Fu
    Challen Fu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • My iPad mini with OS 7.1.2 suddenly will engage in uncontrolled actions such as opening and closing pages, switching between apps, expanding and minimizing pages etc... uncontrollably and I have to shut the mini down to stop the uncontrolled actions

    My iPad Mini #1 with OS 7.1.2 began uncontrolled actions recently.  While reading a book in 3M Cloud App the pages would expand and then minimize on their own and then the uncontrolled action would open other apps and do the same by uncontrollably expanding and minimizing different pages in that app and then the actions would move on to another App and open it and expand and minimize pages and open different pages etc . . .  Initially I thought the problem was connected to the 3M Cloud Library App so I deleted it on my Mini iPad and also in iTunes on my iMac and downloaded a fresh app to install on my Mini.  However, that did not affect the problem.    The uncontrolled actions start in any app and begin every time I open my Mini to the point it is becoming useless.  Please help as I don't have a clue as to the cause of the problem or how to go about fixing it. 

    If this is still happening have you contacted APPLE support with the problem (same question to other posters).
    If it is always after a certain length of time with active use - it may be overheating causing wear and tear on internal components.
    Or - a bug in the software is causing sudden replay of what you just did.
    Had similar issue with work owned IBM think Pad due to age and use in office area that was warm (not my choice) - it behaved as though the track mouse or keyboard was stuck - repeating same single character - open/close folders- would have to do quick shut down by pulling the pad out of dock and pulling the battery out -- solution - was to get new lap top after PC techs cleaned it and it still happened.

  • Trying to override the default af:tree expanded and collapsed icons

    Hi,
    I initially hijacked a thread from 2010 that was vaguely similar to what I need to ask, but a kind forum moderator split my post out to stand on its own merits.
    I am trying to override the default af:tree expanded and collapsed icons I am using the following styles for my af:tree but they are not reflecting any thing on my tree with the styleclass orgType.
    af|tree.orgType::expanded-icon {
    content: url("../images/ac-expand.png");
    cursor: default;
    af|tree.orgType::collapsed-icon {
    content: url("../images/ac-collapsed.png");
    cursor: default;
    af|tree::expanded-icon {
    content: url("../images/folder_open.png");
    cursor: default;
    af|tree::collapsed-icon {
    content: url("../images/folder_close.png");
    cursor: default;
    After working for long hours I realized that there is some problem with af:tree and treeTable. They are not taking the styles where as for the other components, every thing works fine. Is there any way to achieve the task. Could you suggest any alternative way to do this. Thanks in advance. Your suggestions for this task can really help me and my team a lot.
    Regards,
    Krishna Sumanth.

    Hi,
    do the icons show without the style class reference used in the skin file? If so, then the style class for this component might be rendered differently for the tree, e.g.
    .orgType af|tree ...
    Frank

  • Arabic characters is expands and repeated

    Hi,
    Please help in the following problem which is when we print standard
    reports including Arabic characters through SAP system the Arabic
    characters is expands and repeated, we already used device type u201C ARSWINu201D
    Moreover, we already applied sap note u201C822634u201D but nothing is changed
    Also, we changed the language of the local pc to be Arabic but nothing
    is changed
    Furthermore, we logged into system with Arabic language and the problem
    still occurred
    Regards,
    Ahmed

    Hi Vincent,
    As I mentioned in problem details I tried to print standard reports, which is mean the problem appears at the level of the whole system, which is mean itu2019s occurred in any sap screen including Arabic characters such as sap menu in Arabic login, regarding the sap notes u201C809034u201D my release is 7.00.
    Regards,
    Ahmed

  • WRE54G expander and D-LINK 624 router

    Note: DI-624 has 4 lines ethernet wired connectors and 1 wireless antena.
    With WRE54G powered and ethernet connected to the router line 2, the CD used to setup the expander did not worked at first time and resulted in a message in the computer: The WRE54G can not associated this AP in repeater mode.  The next step was to change the configuration of DI-624 by accessing the IP address of the router (Web page of D-link). I put security desable and applied the new configuration to the router but loss the wired (line 1) connection to the internet by DI-624. I reboot the computer and internet came back. I started again with CD setup and the message desappeared but the red light still ON even with the message congratulations in my screen for Linksys setup. When I disconnected the ethernet cable to the expander and after few seconds, for my surprise the both leds went to blue light. When I returned to secure mode in the router, the expander return to red light. Then I decided to run setup with WPA enable until final with congratulations in my screen of Linksys setup wizard but with red light on the expander. After removing the ethernet cable, then after few seconds the Expander turn both leds to blue color. I sent this mail by a computer in the lower floor using this WRE54G expander.

    Well is your D-Link router supports WDS (wireless distribution system), if yes… WRE54G may work with this router…

Maybe you are looking for

  • Excise modvat accounts not defined for GRPO transaction and 58 Excise group

    Hi Experts, When i am doing Goods receipts for Depot for Subcontracting i am getting this error message .Excise modvat accounts not defined for GRPO transaction and  Excise group. For Depot no modvat. is there any configuration setting for depot. Ple

  • [SOLVED] read only filesystem prevents login

    Hi everyone. I have this problem after changing from initscript to systemd and adding an external ntfs-3g drive to /etc/fstab. when i log in i get this message and xfce4 doesnt start : -bash: /home/bb/.xlog : read-only file system ls -la /      gives

  • Windows Server 2012 RDS CALS on Windows Server 2008 R2 Licensing Server

    Hi, at the moment we are installing the first couple of Windows Server 2012 in our infrastructure. Some of them have installed RDS. Now we are wondering whether it is possible to use our existing Windows Server 2008 R2 licensing server for serving th

  • Four Finger Swipe to Desktop

    Has anyone figured out how to revert the four finger swipe up to see the desktop? I've been using that for years and with Mavericks I cannot. I would like to have four finger swip up for show desktop, and swipe down for expose. It's destroyed my prod

  • NullPointerException on wdContext.nodeMyNode().getElementAt(i)

    This is a strange one... The following loop throws a NullPointerException : <br>    int size = wdContext.nodeZoneList().size(); // size is 42...    for (int i = 0; i < size; i++)       // the following throws a NullPointerException when i == 0 !!