Good way to search JTree

Hi,
I have a JTree..and I need to search for a node in the tree by its name. For example if my tree is setup like this:
root
-----> FRUITS
----> apple
----> orange
and i want to search for orange and retrieve the orange node, what is the best way to do this? I was thinking about starting from the root node, and recursively searching the tree comparing the names of the nodes to the nodeNameToSearchFor, if i find a match i return the node.....is there a better way of doing this??
thanks.

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.Enumeration;
public class Test3 {
  public static void main(String[] arghs) {
    DefaultMutableTreeNode root = (DefaultMutableTreeNode)new JTree().getModel().getRoot();
    Enumeration enum = root.breadthFirstEnumeration();
    while (enum.hasMoreElements()) System.out.println(enum.nextElement());
}

Similar Messages

  • What's a good way to search in Leopard when I'm used to Panther's CMD-F?

    I need advice on how to search for files now that I'm using Leopard (instead of Panther) - it's beginning to wear my nerves thin. It was so incredibly easy to search under Panther but under Leopard I find it takes a lot more effort and gives inferior results. I've only had Leopard a few months and I must be missing something obvious.
    In Panther I could type CMD-F and it would open up a separate window where I could put in my search criteria and it would search and present the results in a separate window, sorted in list view. It would let me by default, set up my search criteria, e.g. filename, and always search by file name in designated place(s).
    In Panther if I wanted to search for an item in the active Finder window I could type in the search box in the upper right corner and after I found what I wanted I could click the x and it would go back to being the normal Finder window.
    Not so in Leopard.
    Now in Leopard, if I hit CMD-F it takes whatever window I was working in and turns it into some kind of search dialog. No thanks! If I wanted to search in that Window I would have.
    The problem is that there is apparently no keyboard command to undo this unwanted behavior - I have to take my hands off the keyboard and use the trackpad to click the browser back arrow to get my window back, then I have to open a new window for this search dialog to operate in.
    Next up in unwanted behavior, this search dialog never remembers that 100% of the time I am searching on the file name, and that I never ever ever want to search the "contents". So each time I do the search, I have to again take my hands off the keyboard and click "File Name", and then once again, I have to switch from icons to list view every single time since looking at an Icon with an abbreviated "File Name..." (without all the metadata about the file that one should be able to see in list view) is not as helpful as looking at the list view.
    To make matters worse though, in list view, there's a totally useless column called "Last opened" and there doesn't seem to be any way to change these columns to something useful, such as last modified or created date.
    What do I need to do to make my searches simple and efficient?
    Thanks.

    Start with http://www.pinkmutant.com/articles/Leopard/leospot.html and http://www.thexlab.com/faqs/stopspotlightindex.html, then my mod to Finder's Find at http://www.macosxhints.com/article.php?story=20080229204517495 for what you can change so you can find stuff excluded by the default structure.

  • Any good way to store pdf files in oracle 10g?

    have, i have many pdf files, i want to store in database. Any good way to do that in 10g? Or, I have to go to 11?
    thanks,
    t.k.

    mbobak wrote:
    Justin Cave wrote:
    user10217806 wrote:
    Can I store pdf in blob, and still search words in the pdfs?Probably not, no. If you want to search the data inside Oracle, you'll want to look at Oracle Multimedia.I think the correct answer is "not efficiently". :-)Well, there is nothing that prevents you from building Oracle Multimedia yourself and getting similar levels of efficiency. Other than a desire not to invest dozens of man-years replicating delivered functionality, of course.

  • What's a good way to do a thread dump into a separate file

    What is a good way to do a thread dump automatically into a separate file.
    Example. I run a script to do the thread dump, but unfortunetly, it goes into my stdout log file with the rest of my weblogic errors.
    Any ideas? I want it in a separate file when I run my script?

    Do a Google search on "Drobo S" "benchmark."  I don't have a Drobo S, only the regular Drobo.  But here's a guy who tested one on Windows:
    http://mansurovs.com/drobo-s-review-usb-3-0-2nd-generation
    This one has it a bit faster:
    http://the-gadgeteer.com/2011/12/31/drobo-s-storage-array-review/
    Do read up on a few reviews of it, and be absolutely clear that interface speed (i.e. eSATA versus Firewire versus Thunderbolt) is NOT the same as the performance of the system.  The Drobo cannot keep up with any interfaces... at least the Drobo and the Drobo S cannot.
    I am not using the FS model which is a NAS.  I am using the plain old "Drobo" which is slower than the Drobo S, but that's not to say that the Drobo S is fast, because it is not.
    The Drobo in theory is really attractive: Dead simple to manage, can mix and match drive sizes, offers you some data protection, etc.  However do note that protected storage is not, in and of itself, a backup.  You need other backups besides just the data on the Drobo.  And, because it's so slow, it's really not a great fit for photo storage.  See this review from a guy who used to think the Drobo was great for that and then appended his review:
    http://www.stuckincustoms.com/drobo-review/
    To be as clear as possible, IMO the BEST backup strategy with something like Aperture (so long as your managed Aperture library is of a manageable size, like < 800 GB), is to get a few small portable Firewire 800 drives and keep vaults on each one.  They are great because they are easy to use, to have with you, are bus powered, and you WILL offsite them.

  • Way to search custom engines via right-click/updated version of AcidSearch?

    Are there any current ways to search highlighted text in a customized list of engines via right-clicking it? I used to do it via AcidSearch but it hasn't been updated in years, and the author is not planning on doing so.
    I'm currently using Firefox because it has that capability via add-ons, but I'd rather use Safari as I've noticed that version 4 can handle most pages FF can't, plus it's faster and FF 4 has been postponed to 2011. Thanks
    P.S. I have a list of custom engines in the search bar via Glims but that's not what I'm asking about.

    Hi Mark,
    I think this application has a some potential. However, it has a long way to go to reach that potential.
    Let's start with the toolbar (the blue button that appears on the taskbar) that is created by default when the application is installed. If you'll forgive my bluntness, it's a distracting waste of space and a flagrant misuse of the toolbar user interface.
    If there is something wrong that requires urgent attention (like, for example, the hard disk is failing), then the program should open a dialog box. Otherwise, user notifications should be displayed in -- surprise -- the Notification Area. Please have your developers read and understand the Windows User Experience Interaction Guidelines. 
    And seriously, what is up with the Coverflow-esque marketing garbage on the -- ugh -- "Ultimate Business Tool" tab? If you're wondering why this program has the reputation of being bloatware, look no further than here. This has no business being in a diagnostic application.
    I could say more, but I think you get my drift. Remember the old version of PC Doctor? When all it did was scan your computer for problems and gave you a nice report, without trying to take over your taskbar or sell you stuff? Ah, the good old days.

  • Is there any way to display JTree without using applet

    Hi,
    is there any way to display JTree without using applet . Can we display the JTree in a JSP page.
    With Regards,
    Sheema.

    Not a JTree, per se. But there are Javascript solutions out there and there are JSP tag library solutions which use a JTree on the server side to hold and maintain the data and expanded nodes.
    This is one that I've used before, it's pretty good:
    http://www.jenkov.dk/treetag/introduction.tmpl

  • CAN ANYONE TELL ME A GOOD WAY TO LEARN DREAMWEAVER WITHOUT BREAKING THE BANK?

    CAN ANYONE TELL ME A GOOD WAY TO LEARN DREAMWEAVER WITHOUT BREAKING THE BANK?
    IThe tutorials on the search engines are leading me to dead ends. I'm getting very frustrated.
    Thanks so much in advance

    List of good reference material - that won't cost a cent - all on the web  :-)
    http://www.adobe.com/devnet/dreamweaver/?navID=gettingstarted
    http://www.macromedia.com/devnet/mx/dreamweaver/css.html
    http://www.macromedia.com/devnet/dreamweaver/articles/tableless_layout_dw8.html
    http://www.macromedia.com/devnet/dreamweaver/articles/css_concepts.html
    http://css.maxdesign.com.au/floatutorial/index.htm
    LIST OF CSS TUTORIALS:
    http://www.adobe.com/devnet/dreamweaver/css.html
    HTML & CSS References
    http://www.w3schools.com/
    http://reference.sitepoint.com/css
    TAKING FIREWORKS COMP TO DREAMWEAVER:
    http://www.adobe.com/devnet/dreamweaver/articles/dw_fw_css_pt1.html
    LIST OF CSS TUTORIALS on the Adobe site:
    http://www.adobe.com/devnet/dreamweaver/css.html
    Nadia
    Adobe® Community Expert : Dreamweaver
    http://twitter.com/nadiap
    Unique CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    http://csstemplates.com.au/

  • Any way to search for casts in java source code?

    Anyone know of a decent way to search your java source files to find all the casts?
    I ended up doing a simple text search for
         " = ("(quote marks not included) which works for my code because I am strict about writing my casts with spaces like
         String s = (String) iterator.next();Unfortunately, the above search has all kinds of problems with both false positives and negatives. It picks up lots of irrelevant lines like
         int index = (number > 0) ? 0 : 1;as well as misses casts that appear nested inside expressions like
         ((String) iter.next()).charAt(...)I suppose that one could do a regular expression search for any pair of open and close parens which bound non-blank text, but that would pick up even more non-cast expressions in typical java code.
    I think that the only way to properly do this is to have a tool which understands java syntax.
    Anyone know of an IDE which will do this? Does IntelliJ or Netbeans support this kind of search?
    In case you are wondering why I am interested in this, it is because I am refactoring some code to fully use generics, and searching for casts is one source of identifying candidates for genericity.

    cliffblob wrote:
    Better late than never?Yes!
    cliffblob wrote:
    ...The answer I found to ID unnecessary casts was, using Eclipse IDE, In compiler error and warning preferences to warn on unnecessary casts.Thanks for pointing IDEs out. I just opened IntelliJ, and going back to at least version 7.04 (maybe earlier) they have an inspection for "Redundant type cast".
    cliffblob wrote:
    I would still be interested to know if there is a way to identify casts in general in your source, perhaps now four years later there is a way?The only solutions that I can think of are either a complicated regex search, or you must use some tool like an IDE that understand Java syntax and can determine if a cast is happening.

  • Does anyone know if apple's one-to-one program would be a good way to learn how to use logic pro or am I better off going to school to learn audio engineering or something?

    Of course going to school would be a good option, but I want to know if one-to-one is also a good way to learn how to use logic pro. Has anyone been through the one-to-one program for logic pro and can say that they learned how to use logic pro well because of it?

    For sure, one to one training, if given by a tutor who is capable, will hand you the means to build up self-confidence  and will therefore let you operate the hard/software in an intelligent manner, instead of going for the trial and error method which has its pro's and con's too. Once you've passed this beginners phase you will make your own decisions intelligently and then you will also start to get experience and learn even from your mistakes. Something like that in theory and the rest is up to you!
    Have a nice day

  • Is there any way to tell which formulas a particular cell is in, reverse look-up style? That is, is there a way to search somehow for which formulas in a sheet contain a particular cell in them without opening all of them up? If not, it would be nice

    Is there any way to tell which formulas a particular cell is in, reverse look-up style? That is, is there a way to search somehow for which formulas in a sheet contain a particular cell in them without opening all of them up? If not, it would be nice.
    I'm fixing a Numbers document that I use in business daily that's become overly complicated, but while I want to clear/delete a number of cells in it to clean it up, I'm not sure if those cells are being used as source for other formulas on the page. I don't have to open all my formulas one by one to see if that cell is in there, do I?! That'd be a huge amount of work if I wanted to eliminate say 10 cells to search each formula on the page to see if it is in there or watch all the cells when I delete that cell to see if the numbers change! There's got to be an easier way! Right click doesn't seem to be any help.
    I don't want to damage my daily tool to make it cleaner and reorganize it. Is there really no way to do a reverse look-up of which formulas a particular cell is in?! Any time I click on a formula it highlights all the CELLS in that formula. Why can't I (or can I?) do the reverse and see all the FORMULAS that contain a particular cell?
    As a Numbers document ages or gets used frequently, you can sometimes forget which cells are tied to which formulas. You just look for the results of your formulas. Would be a nice thing to be able to do. Thoughts? Work-arounds? Answers?

    Answer would be no unless application provided such feature. Numbers does not as far as I know.
    Note that even if you have complete list of formulae used in a table, identifying formulae referencing any given cell is not simple.
    E.g., cell T20 is referenced not only in
    =T20+1
    but also in
    =SUM(T)
    =SUM(20:20)
    =SUM(S19:U22)
    =OFFSET(S1,19,1,1,1)
    =INDIRECT("T"&(10*2))
    In order to identify such formula, we have to actually evaluate it to see if it references the given cell. Especially such formula as OFFSET() and INDIRECT() may not be found by static parser because their parameters can be dynamic.
    Sorry to be the bearer of bad tidings.
    H

  • Is there a way to search for skipped songs in my iTunes library?

    I'd like to know whether there's a quicker way to find songs that are being skipped in my iTunes library, than simply manually checking each one.  I've been rearranging and deleting music files in Windows Explorer recently, so I know that there is a chance that I have demolished the link iTunes had to some of the files, but there's no way I can remember what all the modified albums are.  I know how to reestablish the links when I do find a song that is being skipped, but I'd love to go through the whole library and be able to find them all at once.
    The last time I did this, manually - and it seemed to take hours - I did find quite a lot of songs that were being skipped, and was able to reestablish the links or in some cases just delete the song from iTunes since i hadn't wanted it anyway.  But even then it was a little hard, since after manually checking in the quickest way I could - going through the song list and briefly playing each one for a second or fraction of a second - there was no way of sorting the songs by whether they were skipped or not.  I just had to be very careful as I scrolled, to catch each one that had the symbol indicating non-playability.
    All that to say - is there some better, automatic way of searching for non-playable, skipped songs, and is there some way of sorting them out from the rest so one can address them, and not miss any?

    Same question. Used to have an iPod. Lost it (best digital player ever), now I use other portable device. The mp3 files have their id3tag edited in the original file, but the .m4a don't!.
    Want to know someway to write the info from the library to the original .m4a files.

  • Is there a way to search contact list by keyboard

    is there a way to search the contacts list with the keyboard rather than scrolling down via letters? i have like 2000 contacts and some letters are really long. would be much better if there was a search box (like that for SMS) where I could input letters via the keyboard.
    does that exist? have i missed it?

    That feature is not available
    You can request it here:
    http://www.apple.com/feedback/iphone.html

  • Is there a way to search several keywords at a time on the top right search box?

    Hello.
    Let's say I want all the images to appear that have any of these keywords:  "sky, mountain, water".  The only way I have figured out it takes too long and it's tedious.  I open the "find" window and manually add search variables to look for several keywords and file names for the values that I am looking for.
    Isn't there a way to search for files that have any of the keywords I write on the search box by dividing these keywords with commas or any other puntuation? Or am I stuck opening the "find" window and add rows of variables that I want to search?

    I really do hope you are part of the development team for the Bridge.
    If only…
    I'm just a user like you and almost all other participants. Steve (SG) is one of the very helpful Adobe Engineers who occasionally hang around every now and then but they do so out of personal interest and kindness. They also try to be a shortcut to the Bridge engineers, it is no company policy to interact directly with developers on this user to user forum...
    But if I was responsible for resources for the Bridge development team they already would have had loads of money to realize my perfect Bridge and this process would have started from CS3 and above…. but as said, I'm just a humble photographer with no knowledge at all in programming applications and by far not enough money to realize this dream app
    Regarding your Find comments, I do realize there are some extra actions needed and the less you can make the better it would be. However as said, I don't know of any DAM application capable of what you want.
    It is kind of looking into a database and that needs separate criteria to my knowledge. If I had to use the search function that much I would look for a dedicated Digital Asset Manager to do this tasks.
    I'm not very deep in to knowledge about DAM but I use Canto Cumulus Single user for my Archive which is much faster then Bridge (Bridge is much better in other tasks so I need both).
    In Canto you can create a query to customize your own search needs in a better way but this needs some extra knowledge and study, I have only 65 K of files in my archive and searching is not that difficult using the normal route of quick find.
    And to comfort you a little, both Bridge and Canto do reopen the find menu with the last settings which is still not ideal but saves a bit of moves. Having the option to save templates like in batch rename would be a big plus but it is not an option yet.
    And of course, you can also put in a feature request for this:
    http://feedback.photoshop.com/photoshop_family/

  • Premiere Pro CC's sequence lost. Is there a way to "search" for it from outside the project?

    I seem to have lost a sequence created in Premiere Pro CC. I can't find it anywhere inside the Project bin.
    We have so many same-name, older projects (between Auto-Save, different drives and so on) that looking inside each of them would take forever.
    But we do know the name of the sequence. I am wondering  if there is a way to "search" for a sequence name from outside the project?
    Thanks

    there is a way to "search" for a sequence name outside of the project,
    but it would be a pointless waste of time.
    sequences are only saved within the project file itself!!
    We have so many same-name, older projects (between Auto-Save, different drives and so on) that looking inside each of them would take forever.
    better get at it then!
    hahahahahahahaha!!!

  • Is there any way to search for a term using the Firefox search field, and have the results automatically open in a new tab?

    Is there any way to search for a term using the Firefox search field, and have the results automatically open in a new tab? When there was support for Google Toolbar, I was able to do this; now, whenever I want to search for something, I have to open a new tab to do it, and cut-and-paste my search into the search field in the new tab. I used to be able to highlight, drag, and drop something into the search field and have it automatically open in a new tab. This is enough for me to switch to Chrome . . .

    Set a preference to have searches from the Search Bar (upper right) automatically open all searches in a new tab
    #type '''about:config''' in the URL/Location/Address bar and press the Enter key
    #if you see a warning, accept it (promise to be careful)
    #Filter = '''browser.search.openintab'''
    #in the lower panel, double click the item (or right-click and choose "Toggle") to change the value to "true"
    #close the about:config tab and test
    #See:
    #*For help with opening/using about:config, also see: http://kb.mozillazine.org/About:config
    #*Also see: http://kb.mozillazine.org/About:config_entries (click on "Browser", scroll down to browser.search.openintab)
    '''Search Bar''': http://support.mozilla.com/en-US/kb/Search+bar
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    About Google toolbar............
    Google decided that they will no longer produce the Google Toolbar for Firefox 5 and newer version. It is best to move on to other alternatives than to try any "hacks" to the toolbar that may or may not perform in the future. Future versions of Google toolbar will only work with IE7-9. Google Toolbar is not available on any other browser, even Google's own browser.
    *http://googletoolbarhelp.blogspot.com/2011/07/update-on-google-toolbar-for-firefox.html
    *https://support.mozilla.com/en-US/kb/google-toolbar-not-compatible-firefox?s=google+toolbar&r=0&as=s
    *http://www.google.com/support/toolbar/bin/answer.py?answer=1342452&topic=15356%29
    *Google Toolbar 8 FAQ (IE only): https://www.google.com/support/toolbar/bin/answer.py?hl=en&answer=1111588
    '''''To access your Google Bookmarks visit''''' www.google.com/bookmarks.
    Alternatives:
    *http://kb.mozillazine.org/Using_Google_Toolbar_features_without_toolbars
    *https://addons.mozilla.org/en-US/firefox/addon/googlebar-lite/
    *https://addons.mozilla.org/en-US/firefox/addon/gbookmarks-google-bookmarks-fo/

Maybe you are looking for

  • My BB 8320 camera is not working and calls drop after 8 to 10 minutes...

    Hi, Acutally I got this 8320 as a gift 6 months back.  The problem i am facing is that the camera is not starting at all, i have tried troubleshooting it and it is not working still, and sometimes when i am speaking on phone the call drops at the 8th

  • WRT54g on Mac PowerPC G5. Not Working.

    Hey Guys n Gals; Running Comcast Business Class in my restaurant. I have a Mac Pro PowerPC G5 tower running OSX: 10.5.8. The Comcast guy hooked everything up along with the WRT54g i found in the basement (previous owner). Everything worked well, he p

  • It says i have an update, but when i got to the app stores it says no updates available. How can i update the new iTunes?

    I am trying to download the new version of itunes and when I click check updates it says version 11.1 is available for an update. It then takes me to the app store on my mac and tells me that there are no available updates. How can i download the new

  • Creating Error Message in Reports

    Hello, I have a report that has a date range for a parameter screen. The user has requested that an error message will be displayed to prevent the user from making/entering the start date greater than the end date. Could someone please tell me what r

  • Variable Engine Version Compatible​?

    Can I run two different versions of the shared variable engine on different machines and still have them communicate using shared variables? I'm having trouble connecting two computers (One running LV 8.2.1 and the other with CVI 8.5.0) If versions a