Way to expanding jTree

before i add a new node to a jtree some nodes r expanded. so after i added the new node in the JTree i want to show the nodes that were previously expanded in the jtree. what is the way?
I am using,
model : DefaultTreeModel
tree : JTree
rootnode : DefaultMutableTreeNode
Now i am calling the model.reload() method. if the user is selected any node in the tree then i add the new node and call the reload, cause the cast cast exception: can't to cast MyObject to TreeNode. why?

Thank you very much Steve, I was able to integrate
your code in my own application. It's working fine.
I will do more tests with it and let you know about
it.That's terrific Andre. I am very pleased the code worked and helped you. I hope this solution 'nails' the much wondered about JTree refresh problem once and for all.
Should you come across any bugs, or if you think of any means of improvement during your testing, I would be very interested to hear from you.
In any case, good luck with your project, and all the best,
Steve

Similar Messages

  • 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

  • Is there a way to expand the text area of the login/lock screen for the warning message?

    I put our company's standard warning message in the Security & Privacy system preference ("Show a message when the screen is locked.") and it overflowed the allotted text area for the warning message text on the login screen and lock screens.  It seems that the area allows about 250 character messages and I need to provide about 500 characters.  Is there any way to expand the text area allotted for this purpose?
    Bob Reed

    To be a little more specific about the challenge I'm facing, I want to increase the allotted text space for the field I've outlined in the attached image.  Seems like there ought to be a NIB file that could be edited to accomplish this task:
    I would appreciate any advice on which file should be edited to expand the text field.
    Bob Reed

  • Is there any way to expand both the OSX and Bootcamp partitions after imaging the drive to a larger HDD?

    Hey all.  I have been searching forums and racking my brain to find a way to fix an issue I am having with my Late 2011 13" MBP.  SInce I wasn't able to find an answer, I figured it was time for reach out to the community.
    I purchased a Late 2011 13" Core i5 MBP that had a bad HDD from a friend.  I replaced the HDD with an old 100GB SATA drive I had lying around.  My mistake was thinking that it was a 1TB drive.  Regardless, I was able to reinstall Lion to the new HDD and get the machine up and running.  Once that was working, I went ahead and upgraded to Mountain Lion with no issues, then I unstalled Boot Camp and Windows 8.  Everything installed without a hitch and was working great.  Right about that time I realized that I had almost no free hard drive space and discovered my error (the 100GB HDD).
    I pulled the HDD and put in in my ASUS G74SX laptop along with a Seagate 750GB Hybrid Drive and used Clonezilla to do a hardware-to-hardware clone of the drive.  When it was completed, I put the 750GB Hybrid drive in the MBP and it booted right up with no problems.  I was also able to switch back and forth from my Boot Camp drive and everything appears to be working as it should.
    The only problem I have is that both the OSX partition and the Boot Camp partition are still the same size as they were before I cloned the drive.  Try as I might, I can't find any way to expand either one to use the additional 650GB of space that is sitting on the drive unused.  Disk Utility won't allow me to expand the partitions unless the free space is contiguous with the drives.
    Does anyone know of a utility that I can use to fix my problem?  I really don't want to reload everything from scratch.
    Thanks,
    Scott

    You need to combine the libraries on one computer. Otherwise you'll be constantly erasing your iTunes content as you switch computers. iPhone will only sync or manually manage iTunes content with ONE computer at a time.

  • Expand jTree

    Hi,
    I have got question how to expand JTree. I am using netbeans IDE.
    I would like to save information about last visited position in tree and when I open this window again to expand it to last visited node(leaf).
    I have done someting like that:
    String hostName = getHostName();
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(hostName)
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    JTree jTree1 = new JTree();
    jTree1.setModel(treeModel);
    //I have create method to create jTree:
    public void setTree(TreePath path)
    DefaultMutableTreeNode newNode;
    //Here I call method to get all root folders. For root it will be all disks.
    File[] folderList = getFolders(...)
    for(File f: folderList)
    newNode = new DefaultMutableTreeNode(f);
    root.add(newNode);
    Ok. That's how it create jTree. This part of code works correct. I invoke this window with other (main) window. I have got treeNode e.g.
    [ TRAVEL, C:\, C:\Program Files ]
    I strange because I checked that on second level node has leaf but it doesn't handle and folder icon. I have tried jTree1.repaint but it doesn't work.
    How can I expand tree to this node. I have been trying:
    --scrollPathToVisible method
    When I select a node by mouse clicking then tree refreshes and show handle with folder icon and all leafs. I have selected the same node using setSelectionPath(treePath) but it is not working and trying to expand it but it is not working.
    Give me a sign if you need more information.
    Peter D.

    It only took me 20 seconds to do a search and find this, but since you've waited over five hours, here's one result I found
    http://forum.java.sun.com/thread.jsp?forum=31&thread=257313

  • I typed in data into the highlighted text box, and then tried to print my form.  However, when printed, the copy only showed a portion of my answer.  Is there a way to expand Adobe Reader's highlighted text to show my full response, or should I make my re

    I typed in data into the highlighted text box, and then tried to print my form.  However, when printed, the copy only showed a portion of my answer.  Is there a way to expand Adobe Reader's highlighted text to show my full response, or should I make my responses only as long as the highlighted portion allows?

    While printing any pdf file it will print the visible text only. To overcome this, the form needs to be dynamic so that it expands in layout while entering more data. Usually dynamic forms are developed by Adobe LiveCycle Designer.
    ~Deepak

  • When I add a new bookmark, and the (star) Page Bookmarked window appears - is there any way to expand the size of that window so that I can see my entire list of folders when adding a new bookmark to an existing folder?

    When I add a new bookmark, and the (star) Page Bookmarked window appears - is there any way to expand the size of that window so that I can see my entire list of folders when adding a new bookmark to an existing folder? The endless scrolling technique is far too tedious when trying to add a new bookmark, because the window is simply too tiny. Is there maybe a plug-in that will let me grab the corner of that window and re-size it? Thanks!

    I suggest you install the "Add Bookmark to Here2" extension, then you can expand the the list but you will not see the bookmark itself in the list if that is what you wanted. At the top you have three major folders you can select one of them and scroll up and down. Below that you have your most recently used folders and you can select one of them instead and scroll up and down. You can see the folder the bookmark is in -- they get added to the bottom
    If you really want to see the bookmark within the folder the same extension allows you to bring the bookmark to the folder from say the bookmarks sidebar that is why it is named as such. I use it but mainly i use the dialog.
    Please continue reading about bookmarks and some related extensions at
    * http://kb.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox
    * https://addons.mozilla.org/firefox/addon/add-bookmark-here-2/
    * http://dmcritchie.mvps.org/firefox/firefox.htm#addbookmarkhere2
    * http://dmcritchie.mvps.org/firefox/kws.htm
    If you are not using tags at all, you can remove a whole lot of confusion by removing them from the dialog via the extension.

  • How come my iweb template is half the size of my web page is their any way to expand it.

    How come my iweb template is half the size of my web page is their any way to expand it.

    The Inspector is the blue circle with the I.
    The Inspector has 10 icons.
    Each icon represents a purpose :
    Adding hyperlinks,
    Changing the textformatting,
    Changing the width and height of objects,
    Changing the page settings,
    If you're familiar with a wordprocessor you will recognize most icons.
    There's also an often ignored word in the menu bar : HELP
    See if that helps you any further.

  • I installed windows 8 using bootcamp, and realized that i put too little space. If i erase the windows partition and do it all over again, will the product key i used to activate windows 8 the first time still work? Or is there a way to expand it?

    Will the product key i used still work again after reinstalling? Is there any SAFE way to expand the bootcamp partition size?

    If you look in your other posting you will see that I already gave you the answer.
    https://discussions.apple.com/message/21210445#21210445

  • Interactive report - Is there an easy way to expand the width of a column to allow for more data on a line.

    Example.
    One of the columns in my interactive report is labelled Notes.
    The data in the column looks like
    I really
    enjoy
    typing up
    notes,
    please
    disregard
    Is there any way to get this note all on one line - or atleast expand the width to increase or decrease the number of characters per line.
    So either
    I really enjoy typing up notes, please disregard
    Or
    I really enjoy typing up notes,
    please disregard
    Thanks in advance.

    Hi Mikez,
    You can also consider to render your "Notes"-column as a textarea, eg:
    http://apex.oracle.com/pls/apex/f?p=vincentdeelen:23:
    For the text area you can define the default number of rows and column width you want. You render a column as text area with an apex_item function:
    select apex_item.textarea(3,NOTES,1,80) from MY_TABLE
    Where 3 is the index number that you want your NOTES colum to have and 1 and 80 stand for row and column width respectively. When you use apex_item for a column, make sure to set that column as "Standard Report Column" under "Report Attributes".
    More info on apex_item:
    Oracle Application Express APIs
    Regards,
    Vincent Deelen

  • Is there a way to expand the editing bubble in iCal 3?

    I can't figure out how to expand the size of the notes field in the iCal 3.0.3 editing bubble. Is it possible to expand it? You can expand the size of a text area in Safari, but you can't expand the notes field in iCal?!!! Even more frustrating is that when you add more text than can be viewed at once in the notes field, it doesn't scroll to the next line so you can see what you're typing -- you have to scroll manually after each line is entered. What's up with that?!!! I haven't upgraded to 10.5.4 yet -- does that fix any of this?
    I'm very, very frustrated with iCal in Leopard. I want the drawer back -- or at least some more reasonable way of editing events.

    Hi Patrick,
    I'm working on a 30" monitor, so it's effectively 2560x1600.  It only seems to be showing 2 tracks at a time, unless there is a preference or setting I'm missing that I can't seem to find in the documentation.  Here is a screenshot:
    I don't see any areas for expanding the timeline.  I can scroll vertically in the timeline, but I can't seem to actually get a larger static vertical area for showing more tracks at once.  The only vertical resizing widget is to expand the bottom or top panels, not the timeline.
    Thanks,
    Jason

  • Is there a way to expand the number of layers shown in a timeline?

    Hi,
    Right now it seems I can only get two layers to show in the timeline at any given time.  I don't see any way to resize the timeline so that when applying more grading layers, I can see all the layers at once without having to scroll the timeline view.  Is there a keyboard short-cut I'm missing, or some widget on-screen that can let me do this?
    Thanks,
    Jason

    Hi Patrick,
    I'm working on a 30" monitor, so it's effectively 2560x1600.  It only seems to be showing 2 tracks at a time, unless there is a preference or setting I'm missing that I can't seem to find in the documentation.  Here is a screenshot:
    I don't see any areas for expanding the timeline.  I can scroll vertically in the timeline, but I can't seem to actually get a larger static vertical area for showing more tracks at once.  The only vertical resizing widget is to expand the bottom or top panels, not the timeline.
    Thanks,
    Jason

  • Best way to expand a report and export it to PDF?

    Hi, we have created an Excel worksheet with several Power View reports. Some of the reports contain detailed information, such as a table of risks for a project. The stakeholders are quite happy with the interactive feature of Power View, as they can use
    a filter to select a project and view its risks. Also it is very easy to add additional columns in the future (compared to traditional reporting solutions like SSRS that require developers help just to add some columns). However, sometimes the
    stakeholders also need a static pdf output, as some stakeholders do not have Excel 2013, and they may work offline (do not have access to the SharePoint version of Power View either).
    In this static version, the projects must be expanded, so that the pdf contains information of all projects, not just the currently selected one by the filter. Ideeally, if there're 10 projects, each contains 3 sheets, then each sheet will be repeated
    for every project in the pdf, so there will be 30 pages in the output. But Excel's built-in print to pdf feature doesn't seem to support this scenario. In addition, some projects have a lot of risks, and in Power View, a scroll bar is displayed.
    When exporting to pdf, the scroll bar is not expanded. Thus the pdf only displays part of the risks which are currently visible on the screen.
    Is there a way to overcome those limitations, while keep most benifits of self servicing report? We don't mind to look into third party solutions, if the price is reasonable and the solution works nicely with Power BI. Thanks for any thought.
    Shining Oh Blue Star

    This is a bad thing to do with JPEGs. You're better off just reducing the 'q' if you want a smaller/faster/lower resolution image. That way you're throwing away resolution intelligently. Using scaling you're throwing resolution away unintelligently. I was on a project where 40,000 images were scaled when they should have been low-q'd. Don't do it.

  • An Expandable JTree Problem

    Hi, I'm relatively new to creating JTree components, now I have looked at many examples, and this one is nearest (i can see) to how I want my Jtree to look, however it doesn't behave in a way which I would like!
    Firstly, I can set the root node to have as many folders as i want, however they only mirror whats in the first root node, I dont want this - I want to be able to create about 5/6 different roots that will yield different results - I also want after each time you click on a folder, which will ask a question about a patient i.e. "Has the patient a head injury" - click on this then it should come up with "3" more different choices, so altogther want it about 5 deep.
    However, this is what I've got so far - but like I say, its not yielding the results I want, does anyone know how to modify this or can anyone point me in the right direction by starting me off a bit, that would be great!
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class SelectableTree extends JFrame
                                implements TreeSelectionListener {
      public static void main(String[] args) {
        new SelectableTree();
      private JTree tree;
      private JTextField currentSelectionField;
      public SelectableTree() {
        super("Clinical Information Help System");
        WindowUtilities.setNativeLookAndFeel();
        addWindowListener(new ExitListener());
        Container content = getContentPane();
        DefaultMutableTreeNode root =
          new DefaultMutableTreeNode("Begin Clinical Questions");
        DefaultMutableTreeNode child = null;
        DefaultMutableTreeNode parent = null;
        DefaultMutableTreeNode grandChild = null;
        DefaultMutableTreeNode grandParent = null;
        DefaultMutableTreeNode child2 = null;
        DefaultMutableTreeNode parents = null;
        for(int grandParentIndex=1; grandParentIndex < 2; grandParentIndex++) {
          grandParent = new DefaultMutableTreeNode("[Does Patient Have Back Pains?] " + grandParentIndex);
          root.add(grandParent);
          for(int parentIndex =1; parentIndex < 3; parentIndex++) {
            parent = new DefaultMutableTreeNode("[Does the patient also have leg pain?] " + parentIndex +
                                         "." + parentIndex);
            grandParent.add(parent);
            for(int childIndex =1; childIndex < 3; childIndex++) {
             child = new DefaultMutableTreeNode("[are the pains in the lower back?] " + childIndex +
                                         "." + childIndex);
              parent.add(child);
              child2 = new DefaultMutableTreeNode("patient over 60?" + childIndex +
                    "." + childIndex);
              child.add(child2);
            for(int grandChildIndex =1; grandChildIndex < 3; grandChildIndex++) {
               grandChild = new DefaultMutableTreeNode("[Does patient have bladder and/or bowel incontinence?] " + grandChildIndex +
                                            "." + grandChildIndex);
                 child.add(grandChild);
            for(int childIndex = 1; childIndex < 3; childIndex++) {
                child = new DefaultMutableTreeNode("[Has Patient suffered either: appitite/wieght loss/fever?]" + childIndex +
                                             "." + childIndex);
                child = new DefaultMutableTreeNode("[Has pain been 4-6wks leg pain? OR 3-6mths low-back pain?]" + childIndex +
                        "." + childIndex);
                  grandChild.add(child);
        tree = new JTree(root);
        //tree = new JTree(root2);
        tree.addTreeSelectionListener(this);
        content.add(new JScrollPane(tree), BorderLayout.CENTER);
        currentSelectionField = new JTextField("Current Selection: NONE");
        content.add(currentSelectionField, BorderLayout.SOUTH);
        setSize(400, 400);
        setVisible(true);
      public void valueChanged(TreeSelectionEvent event) {
        currentSelectionField.setText
          ("Current Selection: " +
           tree.getLastSelectedPathComponent().toString());
    }

    I'm not really sure what your problem is, for I don't see what you mean by "mirror". If it is you have but one root node, but wanted to have many instead, then you'd simply need to call setRootVisible(false); on the tree.
    As a sidenote, I don't think it's a really good UI for what you're doing, but after all, I haven't got the whole picture.
    Now, what is it you mean by: its not yielding the results I want ?

  • Best way to expand MacBook Air SSD

    My daughter is a Medical Student with a 2013 MacBook Air 256 SSD.  I should have anticipated her video, (lecture), storage requirement.  Anyhow what is the best solution to expand her storage capabilities beyoun 256 gb and maintain some sense of portibility?  A high capacoty USB drive?

    You would have to buy a third-party piece of hardware to do that. There is no other way to connect two monitors to a computer that has only one video out port.
    You might check out www.matrox.com.

Maybe you are looking for

  • Table does not exist in system after DB Connect

    Hi Everyone, I must extract data from a oracle db.  I create a source system with DB Connect and it's connect successful. Later, i create a datasource for that source system. but it show the table does not exist in system. I'm sure the table is corre

  • [JS CS3] Crash by using FindChange-Script

    This is a very unusual and mysterious problem: I've a document within 10 stories (my chapters) und I want to replace all quotation marks by using the FindChange-Script ... text    {findWhat:"^{"}    {changeTo:"<00BB>"} When I execute the script about

  • Best value mic for Podcast recording

    Can you recommend a microphone for recording podcasts, apart from the built-in MacBook mic? Or, how good is the sound quality from the built-in? Podcast worthy? Many thanks!

  • Data Modelling Problem with many additional Fields

    Dear All I am extracting transactional data from a CRM system where a number of  Customer Fields have been added. There are some 150 additional fields which are all included in a User Append structure and are all related to the transaction ( not mast

  • Software under creation - what DOES that mean?

    Hi, I'm just curious, the belle availability information dated 7th Feb for my (fantastic) N8 shows that the software is "under Creation". What, exactly, does that mean?    How long does this process normally take?  Days, weeks, months?  Is the carrie