Using a JTree as an explorer

Hi all of you there!
I made a JTree from my local disk (c:/) en in that JTree I can navigate through al the folders of my C-disk.
Now I want to have the directory of the file that is highlighted. I already try lot of things but no one work.
The best thing I get was: "nodeinfo = [Ljavax.swing.tree.TreeNode;@110c31"
{code}
     private JScrollPane getFileScrollPane(String file) {
if (fileScrollPane == null) {
               fileScrollPane = new JScrollPane();
               fileScrollPane.setPreferredSize(new Dimension(200, 400));
          File root;
          FileTreeModel model;
          //JTree tree;
               root = (new File(file));
     model = (new FileTreeModel(root));
     tree = new JTree();
     tree.setModel(model);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener(tree);
               tree.addTreeSelectionListener(new TreeSelectionListener() {
               public void valueChanged(TreeSelectionEvent e) {
                    DefaultMutableTreeNode node = new DefaultMutableTreeNode();
tree.getLastSelectedPathComponent();
                    /* if nothing is selected */
               if (node == null)
                    return;
               /* retrieve the node that was selected */*
               Object nodeInfo = node.getPath();
               //Object nodeInfo = node.getUserObject();
               System.out.println("nodeinfo = " + nodeInfo);
               System.out.println("root=" + node.getParent());
     fileScrollPane = new JScrollPane(tree);
     fileScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
     fileScrollPane.setPreferredSize(new Dimension(315, 300));
          return fileScrollPane;
     }{code}
the String file contains "c:/"
I hope that someone can help me

Hi, thanks for your help!
But it won't work.
Now I get the following error: (I paste everything in here, maybe someone wants to see it all)
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.io.File cannot be cast to javax.swing.tree.DefaultMutableTreeNode
     at main.Main$10.valueChanged(Main.java:553)
     at javax.swing.JTree.fireValueChanged(Unknown Source)
     at javax.swing.JTree$TreeSelectionRedirector.valueChanged(Unknown Source)
     at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(Unknown Source)
     at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(Unknown Source)
     at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(Unknown Source)
     at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(Unknown Source)
     at javax.swing.JTree.setSelectionPath(Unknown Source)
     at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source)
     at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(Unknown Source)
     at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(Unknown Source)
     at java.awt.Component.processMouseEvent(Unknown Source)
     at javax.swing.JComponent.processMouseEvent(Unknown Source)
     at java.awt.Component.processEvent(Unknown Source)
     at java.awt.Container.processEvent(Unknown Source)
     at java.awt.Component.dispatchEventImpl(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Window.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)

Similar Messages

  • I am a new Mac user.  How do I easily move files to new locations and folders in Finder, like I was used to doing with Windows Explorer?

    I am a new Mac user, converting from the Windows world.  How do I easily transfer files from one folder location to another in Finder, like I was used to doing in Windows Explorer?

    You can expand Finder into multi-panes, I am not at my Mac right now to get the exact key strokes so don't want to mislead you.  Do so many things on auto-pilot that when someone asks I need the machine so I can get the exact things to click on.
    But you can get the multi-pane view and drag and drop from pane to pane.

  • Urgent::using ColdFusion MX7 in Internet Explorer 7.0

    please help..
    Can someone please tell me whether there are any issues in displaying applications developed using ColdFusion MX7 in Internet Explorer 7.0

    Please see following link hope may be useful to you:
    http://corfield.org/blog/index.cfm/do/blog.entry/entry/IE_Update_and_ColdFusion_MX_7
    Thanks.

  • I would like to use Mozilla instead of internet explorer

    How to install Mozilla and use it instead of Internet Explorer? I heard it is better.

    https://support.mozilla.org/en-US/kb/install-firefox-windows

  • Using A JTree Model to Open Files

    Hello all,
    How can I open the files that are displayed in the JTree?
    I have a JTree with names of the files that are saved on my hardesk, but I can't use the JTree to open these files.
    I have already implemented the TreeSelectionListener.

    This:
    I have already written methods for openning and
    saving files doesn't line up with your OP:
    How can I open the files that are displayed in the JTree?It doesn't matter how you get the name, you open then the same way?
    If you have written a tree listener then you know which file was selected.

  • Creative Zen 16GB playlist using anything but Creative Media Explore

    I need some suggestions for creating a playlist using anything but Creative Media Explorer. I hate drilling down throught the artist/album folders! I hate that I can't view my playlist in Media Explorer (Manage or Create Playlist) as anything but filenames. With a long playlist, it's hard to see if you've already added the song.
    I can see my playlist on?WMP and Rhapsody but can't edit. Any other third party software that would help me? I guess Creative Media Source won't?work with the Zen 6GB. Thanks!

    @ It could be incorrect ID3 tags on your .mp3s, if the source for your music had the wrong ID3 information, your Zen won't show the correct information unless you use an? ID3 Tag Editor to correct the source.

  • How to view all files / folders using a Jtree

    Hello,
    I am developing a 'windows explorer' type application and need to create a JTree which displays all files and folders on a local and remote PC in the same way that windows explorer works.
    Can anyone recommend a good way to read all files / folders and display them in a JTree?
    Thanks in advance!!!!!!

    Can anyone recommend a good way to read all files /
    folders and display them in a JTree? Don't even try to read all the files at once; it could take too long and could consume a lot of memory. Create a JTree model that only reads the children of node when required. I use a simple cache (I hate using a cache but in this case it is needed) to minimise the number of disk reads but I use a TreeExpansionListener to remove items from the cache when a node is about to be collapsed e.g.
        public void treeWillCollapse(TreeExpansionEvent event)
            Object lastElement = event.getPath().getLastPathComponent();
            childCache_.remove(lastElement);
        }

  • Error while using Analytic view with BO explorer

    Hi,
    I am trying to create an info space based on my Analytic view which has input parameters. The infospace is validated and indexed without any issue. However when I ran the view, I get an error (50011) as it is unable to fetch any results. I tried using an infospace based on Calculation view with input parameters and the explorer view works without any issue.
    Has anyone faced similar issues?
    We are using HANA SP 6 rev 67 and BI 4.0 SP 4.
    Also is there a way to enable input prompts for the users when they refresh the BO Explorer view? If not currently available is there any work around ?
    Thanks

    Hello George,
    I don't have any personalization set on the info space. Also I am using mapped Account in BI to connect to HANA. The confusing part is that it is able to validate the infospace with the input parameters and index it. However query does not return any results. I even tried running the same query which explorer sends to HANA in the SQL editor and there too the same results,the query does not return anything. The model does return data when I do a data preview and if accessed from other tools like AAO.
    Also when I use SSO connection to HANA, indexing of the infospace fails. Where can I see the error log?
    Thanks,

  • How can I make Outlook use Firefox instead of Internet Explorer and can I turn IE off without hurting anything else on my machine?

    I would like to use Firefox for Outlook Express. I can't find an option in Outlook or Firefox to make Firefox the default to access the web for email through the mail client.
    Also, is there a way to stop IE so that it isn't used at all by any program in my machine?
    Thanks
    CajunReb

    Matt,
    I've tried that. When I go to outlook express, then to tools, options, then connections tab, it says "Outlook shares your connections with Internet Explorer, click the change button to modify these settings", but I don't see a way to do that. It just offers the option of changing settings for connecting to the internet, not which browser.
    I'm stumped

  • Weebly Editor on Netfirms will not open using Firefox but does with Explorer

    I have been trying to open the Weebly Editor on Net firms using Firefox but it won't open it. Explorer opens it though. I talked to the techs at Net firms and they told me to dump my cache, make sure plugins are up to date etc. Still nothing. They say Firefox works fine on their site. When I click on edit website, it goes to the next page but just stays blank. Does anyone have any ideas? Thanks.

    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * On Windows you can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * On Mac you can open Firefox 4.0+ in Safe Mode by holding the '''option''' key while starting Firefox.
    * On Linux you can open Firefox 4.0+ in Safe Mode by quitting Firefox and then going to your Terminal and running: firefox -safe-mode (you may need to specify the Firefox installation path e.g. /usr/lib/firefox)
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    [[Image:FirefoxSafeMode|width=520]]
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    [[Image:Safe Mode Fx 15 - Win]]
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''

  • Why can't I change the size of the page using the two finger pinch method on my touchscreen computer when using firefox. it works with explorer. thanks

    I should be able to adjust the screen size using two fingers. It works with explorer but not with firefox. Is there a setting I need to adjusrt. Thank You

    Please [https://support.mozilla.com/en-US/questions/900198 see this.]

  • Aleks 'higher ed' -- precalcus -- won't run on Firefox for windows; I want to use Firefox, not Chrome or Explorer per the ALEKS recomendation; what should I do

    I tried to join ALECKS. I received a Java warning that Google has not fixed a problem that makes Firefox running on Windows unstable when using a Java version = or > 7.0. I don't want to follow the Alex recommendation to use Chrome or Explorer; using the ALECKS path to install a 6.x version of Java didn't work for me. I want to use Firefox as my only browser. If that is not possible re: ALECKS, I will use the Khan Academy in lieu of ALECKS.

    check your plugins
    *https://www.mozilla.org/en-US/plugincheck/

  • How could I use FAVOURITES imported from Internet Explorer

    I use Google Chrome. However I get adverts, which obstruct my work. As I cannot get rid of these adverts, I want to try Mozilla Firefox. I have imported favorites from Internet Explorer but I do not know how to use them. I do not see any button or icon for this purpose. I should be grateful for your help.
    FB321

    Web page have ads, and there are add-ons to suppress some of those if you find them troublesome.
    Bad add-ons can inject additional ads into pages. Sometimes some "freeware" you install can include these ad injectors which then infect all of your browsers. If you suspect anything along those lines, here's my suggested procedure for tracking down and cleaning out bad add-ons. Sorry for the length -- it's not as bad as it sounds:
    (1) Open the Windows '''Control Panel''', Uninstall a Program. After the list loads, click the "Installed on" column heading to group the infections, I mean, additions, by date. This can help in smoking out undisclosed bundle items that snuck in with some software you agreed to install. Take out as much trash as possible here.
    (2) Open Firefox's '''Add-ons page''' using either:
    * Ctrl+Shift+a
    * "3-bar" menu button (or Tools menu) > Add-ons
    In the left column, click '''Plugins'''. Set nonessential and unrecognized plugins to "Never Activate".
    In the left column, click '''Extensions'''. Then, if in doubt, disable (or Remove, if possible) unrecognized and unwanted extensions.
    Often a link will appear above at least one disabled extension to restart Firefox. You can complete your work on the tab and click one of the links as the last step.
    Any improvement?
    (3) You can search for remaining issues with the '''scanning/cleaning tools''' listed in our support article: [[Troubleshoot Firefox issues caused by malware]]. These on-demand scanners are free and take considerable time to run. If they finish quickly and especially if they require payment, you may have a serious infection. I suggest the specialized forums listed in the article in that case.
    Success?

  • On the same machine, Adobe Flash Player installs and operates satisfactorily in Internet Explorer but does not install at all in Firefox. What to do? I'd prefer using Firefox in lieu of Explorer.

    The machine is running Windows 7, 32 bit. Downloaded Firefox today (Jun 7, 2011) so it should be the latest version. Same with Flash Player.

    CJS23 wrote:
    Hi
    Javascript no longer works in Internet ExplorerJavascript has nothing to do with Java.
    The fact that I have no problems whatsoever in Firefox leads me to believe that the issue lies with IE.Sounds about right.
    When I go to check if I have Java at http://java.com/en/download/help/testvm.xml?ff3 I get a pop up log in box saying "the server java.com at SUN ONE web server requires a username and password" (when using IE - Firefox / Opera display the dancing duke symbol as they should)
    It sounds like you are now talking about having Applets run in your browser. Before you talk to IE customer support, you should nail down what your problem actually is, JavaScript or Java Applets, they are different technologies belonging to different people and implemented very differently.
    What's going on?You have a problem with Internet Explorer. Either ask their customer service or stop using it.

  • COMPLAIN TO APPLE ABOUT USE OF SITES UNDER WINDOWS/EXPLORER

    I filed the following complaint to Apple. I liked Apple very much since I changed two years ago. But iWeb changes this perception drastically! Its site do not work under IE/Windows!!!
    File under 'feedback' button at 'Support iWeb' site.
    "Apple people, could you please have a look at the very many people including myself complaining about the fact that we all bought iWeb which performs beautifull on a Mac but DOES NOT perform if used through Internet Explorer/Windows?
    I am seriously thinking to reclaim my money because Apple should already have taken care of this issue."

    There is a general reluctance of PC users to upgrade version to version. I can't really blame them with all the security holes and the generally cobbled together and intertwined nature of PC software/hardware. My work still uses some version of IE 5, I think...and yes, it barfs on the original website in question. I'm constantly bothering my IT folks about upgrading and all I get is a definite maybe. Of course, work computers are for work and the IT department really do see every application update as potentially that last straw that brings the whole thing down.
    Thankfully, someone with admin rights secretly installed the latest FireFox version for me on my workstation.
    James
    http://www.dirtdoog.com/

Maybe you are looking for