JTree open folder on single click

I have a custom tree that expands JTree and would like the folders to open/close on a single click rather than a double click (per user requirements). Should I do this with a mouse listener and based on the node do something, or is there another way? Also, how can I programatically toggle a folder node opened/closed state?
Thanks!

I have a custom tree that expands JTree and would
like the folders to open/close on a single click
rather than a double click (per user requirements).
Should I do this with a mouse listener and based on
the node do something, or is there another way? Also,
how can I programatically toggle a folder node
opened/closed state?
Thanks!Here's one way:
someTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent e) {
                if (!someTree.isExpanded(someTree.getSelectionModel().getLeadSelectionRow())) {
                    someTree.expandPath(e.getNewLeadSelectionPath());
        });

Similar Messages

  • Open Folder by double click using java.awt

    Hello Guys,
    I have a problem. I m listing directory in List(java.awt). When i single click on directory it will open. But how i can double click on that directory then and then it will open otherwise not. By using JAVA.AWT.

    According to the documentation for java.awt.List "When an item is selected or
    deselected by the user, AWT sends an instance of ItemEvent to the list. When
    the user double-clicks on an item in a scrolling list, AWT sends an instance of
    ActionEvent to the list following the item event. AWT also generates an action
    event when the user presses the return key while an item in the list is selected."
    If your directories are "opening" (whatever that means) in response to a single
    click, that it because of how you have written your code. Change it so that action
    events rather than item events cause the opening to happen.

  • Wireless Mouse does not Open Folder when double clicking

    Hi. I just upgraded my operating system on my iMac from OS 10.5.8 to Maverick Version 10.9.5. Prior to this, I used to be able to double click on the left key of the mouse to open a folder. The only option is to right click on the folder and select the open in new tab option from the drop down menu. I checked system preferences, mouse, and slowed down the speed to half. Unfortunately, I no longer have a double click to open or view option. Please help. Thank you.

    Have you checked to see if your settings are still set correctly.   Go to Systems Prefs > Keyboard and Mouse > trackpad and see if the double click setting is (ideally) set midway along the slide.   If it isn't, move it there.

  • Making a specific file or folder single-click

    hey
    Is there any way on OS X to make a specific file or folder open by a single click. I want to create some tasks in automator and just want to open them using a single click.

    Used to be in Mac OS 9. There is a Cocoa version of the Launcher here:
    http://personalpages.tds.net/~brian_hill/launcher.html
    Maybe you can work something with him out to do something scriptable.

  • Single click to open apps

    Hi.
    Is there a way I can set my applications to open with a single click like they do when an icon is clicked in system preferences and like they do from when you launch them from the dock? Thanks.

    If you are thinking of a way to have all your applications handy but not clutter up your dock, you can drag the whole applications folder into the left hand side of the dock (where the trash can is). Use the source folder in your root directory, not the side panel. This inserts an alias - all you have to do is control click it and you have a list of all the items inside there that will open with a single click
    Hope that helps
    DKR

  • How do you change to single click to open files and folders?

    How do you change from double clicking a file/folder, to single clicking (web style)?

    Finder > Preferences
    Turn it off it irks you. I find it exceedingly useful.

  • Single Click in Finder Opens Everything :(

    We're having the oddest problem I've ever seen in 20+ years using macs.
    This machine I'm on lately started acting funny. When I click in the finder on any document, a single click to select or highlight automatically opens the file, as if I double-clicked.
    I can't select a file to change it's name, for example. I have to Get Info and change the name that way, becuase no matter what I do the files open with a single click/select.
    I have altered the mouse settings in SP and it doesn't change the result. I also switched mouses to make sure it's not that.
    I really don't want to re-install the system, but is that probably what needs to happen?
    Has anybody ever heard of this and have any ideas?
    Thanks much!

    Hi BulaRae,
    Have you tried creating a new account and see how your Finder works in that User acct? (That will tell if your problem is systemwide or limited to your User acct.)
    Open System Preferences > Accounts > "+" make it an admin account.
    If this works, then log back into your problem account and navigate to ~(yourHome)/Library/Preferences and trash these two files:
    com.apple.finder.plist
    com.apple.sidebarlists.plist
    Then log out and back in again. Or restart.
    (You will have to reset a few finder prefs the way you like them.)
    Let us know.
    -mj
    [email protected]

  • Acrobat 9 fails to open with single click.

    facts:
    Bridge created: the pdf that fails is PDF 9, PDF Producer: PDF Library 9.0, PDF version 1.6, 448 kb, [a single page thumbnail creation by Adobe bridge] opens with acrobat 9.0, application = empty
    windows Access created: pdf that works with single click: size = 13.1 mbytes, PDF producer = distiller 9. [created inside windows office access 2000], pdf version = 1.5, application = acrobat pdf maker 9.0 for access.
    Now for the annoying parts
    move both PDFs to their own folders. single click both, the one created by access opens. the one created by bridge doesn't, Buuutt it does stick an adobe pdf in the task manager showing adobe pdf IS open because of the mouse click, but it doesn't open the file, kill the adobe task. Also this one created by bridge, I insert the image into access, and access opens it just fine to my annoyance. I have to immediately close it in acrobat to do anything with the access page I've just imported the image into.
    create shortcuts on the desktop, and they both open from the shortcuts with a single click.
    Oh yeah the bridge one opens if I right click, and choose to open with acrobat 9 at the very top of the right click menu.
    What's going on here ? And how do I get the bridge file to open with a single click and not making it a shortcut ?

    I received the same error today. It's been working for weeks. At the moment I am working on Windows 8 Consumer Preview with Office 2013 installed on an x64 platform, however that hasn't bothered it since it was installed. However, today I received an Adobe Update, I don't even remember what products were being updated, the update screen popped up, downloaded, installed, the progress bar got to 100% and said 2 seconds remaining and then the module crashed. The cloud activation hasn't worked since. I first get a message that says "We are unable to activate CS6 Creative Cloud Membership Subscription Edition", below that it says, "Product Activation is required to use this product" and below that it says "You must have an active internet connection to activate this product. Please check your connection settings and choose try again." When you click on Try Again, it sends up a new message box that says "Activation Failure". Needless to say I have an active connection. Even though it always worked before, I added Adobe Application Manager to the Windows 8 firewall exceptions list, still no dice. I've rebooted the computer twice.
    Update: Turned out this followed another defect identified earlier. It is peculiar to Acrobat X. If you open a different application in the suite, login if asked, then close the application, Acrobat will function again normally.
    ---Mike

  • Single click open - where?

    I have a very lame question. I changed a setting that caused SQL Developer 1.5 to no longer open an object (such as a procedure) when I select it in the connections window. I have literally searched for hours but can't find that setting again. Please tell me where to find that setting.

    I believe what you're looking for is under
    Tools --> Preferences --> Database --> Advanced Parameters: Open Object on Single Click.
    Ed. H.

  • Default "OPEN" folder

    Lately, Photoshop CC always opens a default folder-which is several clicks away from the folder I am using. How do I set it to default to the most recent open folder when I click "OPEN" ?

    Cohec,
    It there a way to change the preference to open the last opened folder?
    As far as I know that is the expected behaviour in all versions, so something seems to be wrong.

  • Single Click a Book to display html assigned

    Hi,
    I have a book which has an HTML file attached to it. How do I
    set this so that when a user just clicks the book the topic linked
    to it opens? It appears right now my users are having to
    double-click it. But topics underneath are all single click.
    Thanks,
    Mary

    Hi Mary
    Normally if you have a topic assigned, it will display by
    simply clicking the book. Are you asking about also having the book
    open on a single click?
    If so, that's done in an option when you compile. If you
    click File > Generate and get to the intermediate dialog, look
    near the bottom for a button labeled Edit... and click it. You
    should then see another dialog appear with a couple of tabs. Click
    the tab labeled TOC Styles. On this tab are a bunch of check boxes.
    The one you want is labeled "Single click to open books".
    Cheers... Rick

  • I have to "single-click" twice (not double click) to open an item in the Dock.

    Can someone confirm if this is Expected Behavior??   (OS = Mavericks)
    If you have Assigned an application in your Dock to a Desktop & Display in the application's Dock >> Options  (ex: Assigned To:  Desktop on Display 2):
    Click once on the application icon in the Dock, the application's Menu will populate on the top of your screen, but not the application itself (yet), click the application icon a second time, the application will now show too. 
    Docked Applications that do not have an Assigned To: Desktop & Display in the Dock options, you only need to single click.
    FYI:
    For odd Dock behaviors otherwise try this:
    You may have a corrupted Dock preferences file.
    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Type or copy paste the following:
    ~/Library/Preferences/com.apple.dock.plist    (plist = preference list file)
    Click Go then move the com.apple.dock.plist file to the Trash, or move it to your Desktop.
    Restart your Mac and see if the behavior is resolved.  You will have re-configure your Dock settings.

    From where are you launching Mail? The only place, unless I've missed or forgotten something, you can launch an application with a single click is from the Dock. Is this what you're doing, or are you attempting to launch Mail from the Applications folder?
    Regards.

  • I used to single click to open mail & now I have to double click.  I have not changed preferences.  Any suggestions?

    I have always single clicked to open mail.  Now I have to double click.  I have not touched preferences or made changes.  Any suggestions?

    From where are you launching Mail? The only place, unless I've missed or forgotten something, you can launch an application with a single click is from the Dock. Is this what you're doing, or are you attempting to launch Mail from the Applications folder?
    Regards.

  • Single click folder action script

    Hi
    Long shot question here:
    I am wanting to set up a folder action script that is activated by only single clicking a folder (selecting), very much the same as "Macintosh HD:Library:Scripts:Folder Action Scripts:open - show comments in dialog.scpt", the dialog will display when the folder is selected, not opened.
    Is this possible with applescript, or a combination of AS and "do shell script"? if so can I get some pointers please.
    Cheers
    Budgie

    Hello
    The Standard additions dictionary claims:
    adding folder items to: Called after new items have been added to a folder, but only when the folder’s window is open
    adding folder items to alias -- Folder receiving the new items
    after receiving a list of alias -- a list of the tems the folder received
    closing folder window for: Called after a folder window has been closed
    closing folder window for alias -- the folder that was closed
    moving folder window for: Called after a folder window has been moved or resized
    moving folder window for alias -- the folder whose window was moved or resized
    from bounding rectangle -- the previous coordinates of folder window (you can get the new coordinates from the Finder)
    opening folder: Called after a folder has been opened into a window
    opening folder alias -- the folder that was opened
    removing folder items from: Called after items have been removed from a folder, but only when the folder’s window is open
    removing folder items from alias -- the folder losing the items
    after losing a list of alias -- a list of the items the folder lost. For permanently deleted items, only the names (in strings) are provided.
    Other actions , like single click, are NOT treated.
    Yvan KOENIG (from FRANCE dimanche 29 janvier 2006 19:12:18)

  • Hi when i open my application folder, all the application is shown in trash folder. when i click the application it says this app is in trash first move it out. and when i try to open through finder go it says this file doesn't exist. can some1 plz help?

    hi when i open my application folder, all the application is shown in trash folder. when i click the application it says this app is in trash first move it out. and when i try to open through finder> go it says this file doesn't exist. can some1 plz help? how can i put all my application through application folder?

    Something really odd is going on. In your first screen shot, I noticed that the Applications folder does not have the proper icon displayed in the side bar. Also, in the title bar it lists it as Applications 08-59-29-909.
    Not sure where it's picking up that odd name, unless it's because it's still truly within the Trash folder.
    Try this. In the Finder > Preferences > General > turn on "Always open folders in a new window". (I have a feeling you have the default setting with this off).
    Now, in Finder > Go > move down and open the Applications Folder from there. Now open the folder where you see all your applications that you show in your screen shot, select all, and move them to this true appliactions folder.
    This is what you should properly seeing (but with different apps listed):
    See how the Applications folder has the icon of the letter A shaped with a pencil, ruler & pen.

Maybe you are looking for