Getting a TreeNode with its Children

Hi Guys
DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();I'm using the above statement to get the selected node ofa JTree, the problem being the node returned does not contain any children and it definitely has children below it in my JTree.
Any Ideas.
Thanks

Try:
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)(node.getParent());
                                                 for (int i = 0; i<parentNode.getChildCount(); i++)
                                                      DefaultMutableTreeNode childNode =(DefaultMutableTreeNode)(parentNode.getChildAt(i));
                                                      Object fileChildNode = childNode.getUserObject());
                                                                                                       }Where node is the current selected child node

Similar Messages

  • How to duplicate a node along with its children in a JTree?

    Hello,
    Can anyone tell me how to duplicate/create a copy of a node
    along with its children?
    Code snippets will be appreciated.
    Thank you.

    It cant be done . You have to write a z pogram to update the data in the new dbtable.

  • HT201269 Hi. I have shared an Apple ID with my children for some time.  As they are getting older they do not wnat me seeing all their messages, photos etc so want their own accounts.  How can they access their purchased music and apps on the new account

    Hi. I have shared an Apple ID with my children for some time.  As they are getting older they do not wnat me seeing all their messages, photos etc so want their own accounts.  How can they access their purchased music and apps on the new account please?

    Yes.
    On their iOS devices, under Settings>iTunes & App Store, they should use your Apple ID. When they log into iCloud, iMessage and Facetime, they should use their personal Apple IDs.

  • I have been offered cc 2014 for 29.99 and its says contact the support team to see if I qualify - trying to get to the support team option by telephone just seems to send me in a loop - getting pretty disgusted with all the rigmarole just to get a somethi

    I have been offered cc 2014 for 29.99 and its says contact the support team to see if I qualify - trying to get to the support team option by telephone just seems to send me in a loop - getting pretty disgusted with all the rigmarole just to get a something

    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • How to get string from jtextpane along with its attributes

    sir,
    How to get string from jtextpane along with its attributes
    i,e font,size,style,color etc.
    please help me out.
    my mail id is [email protected]

    JTextPane extends JTextComponent
    JTextComponent.getDocument()
    a Document is a set of Element, see Document.getRootElements(). Each Element has attributes, stored within an AttributSet object see Element.getAttributes()
    a Document can also be rendered as a String, see Document.getText( offest, length ), use it with 0 and Document.getLength() as parameters.

  • Query to get value sets associated with its descriptive flexfield

    Hi All,
    Here i have a issue
    I am trying to get Value sets associated with its descriptive flex field of Receivable application and
    also if i want this for particular responsibility i.e., GW RBC Receivable Super User.
    I hope u got it.
    Please suggest me some query to get this.
    This is very important for me.

    Hi, I think your question should be addressed to the OEBS experts

  • HT5621 how can i unlink an iphone from its previous users email so i can turn it on to my own email address, also i cant get in contact with the previous owner

    how can i unlink an iphone from its previous users email so i can turn it on to my own email address, also i cant get in contact with the previous owner

    If you are referring to Activation Lock, the password for the Apple ID signed into the device is required, there is no way around this.  If you do not have the information and cannot contact the previous owner, the device is useless.

  • [svn:osmf:] 9829: Extending ILayoutContext with an ' updateIntrinsicDimensions' method, that the ILayoutRender uses to inform the context that context' s intrinsical dimensions may have changed because its children got layed-out .

    Revision: 9829
    Author:   [email protected]
    Date:     2009-08-31 06:38:08 -0700 (Mon, 31 Aug 2009)
    Log Message:
    Extending ILayoutContext with an 'updateIntrinsicDimensions' method, that the ILayoutRender uses to inform the context that context's intrinsical dimensions may have changed because its children got layed-out. Adding implementing code to LayoutContextSprite and LayoutRendererBase.
    Modified Paths:
        osmf/trunk/framework/MediaFramework/org/openvideoplayer/layout/ILayoutContext.as
        osmf/trunk/framework/MediaFramework/org/openvideoplayer/layout/LayoutContextSprite.as
        osmf/trunk/framework/MediaFramework/org/openvideoplayer/layout/LayoutRendererBase.as

    A slow boot time can be caused by login items.
    User Login Items:
        Flux
        NoSleep
        ClipMenu
        Canon IJ Network Scanner Selector2
        BetterTouchTool
        USBOverdriveHelper
        TotalFinder
        Gmail Notifr
    Open System Preferences > Users & Groups > Login Items
    Remove one login item noted above then restart your Mac to test. It may be one or multiple items causing the slow boot.

  • I accidently deleted an app off my iphone, and its not on my computer, how do i get it back with out having to pay for it again

    I accidently deleted an app off my iphone, and its not on my itunes account on my computer, how do i get it back with out having to pay for it again?

    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Plssss help i beg all of u after hard reset my iphone got stuck with an apple symbol i thought it will get on and now the battery got empty and pressing power on button it switch on showing red battery and gets off and also its not connecting to my l

    Re: plssss help i beg all of u after hard reset my iphone got stuck with an apple symbol i thought it will get on and now the battery got empty and pressing power on button it switch on showing red battery and gets off and also its not connecting to my la
    its not connecting y?i think its software got corrupted,i think i should charge it first with a battery charger and when apple logo appears i should connect with pc,but i dont know how 2 open the back cover and how 2 remove the battery,i phone battery is removable or not?i mean it is fiz or wot?

    Recharge.  Reset.  Restore.

  • HT201441 i bought a apple iphone 4s and it came locked from ebay & i cant get into contact with the guy its no possible way ! and im pretty ******

    bought a apple iphone 4s and it came locked from ebay & i cant get into touch with the guy its no possible way annd im getting ****** !

    File a complaint with eBay to get a refund on the useless iPhone.

  • I found a phone and its icloud lock what can i do to get in contact with the person to see what they want to do wit the phone

    hi i just want to see what i can do to get in contact with the user of the iphone 4 i found. I just want to see what they want to do wit it so that i can use the phone or give it back to the person that lost the iphone 4 thank you

    The best thing you can do is turn the phone over to your local law enforcement as a lost/found device. 

  • Drag a container and its children

    Hi,
    How do i drag a container and its children? 
    I see you can drag something and its parent, but i don't see how you can get the child from the draginitiator. 
    Thanks

    I've had a chance to play with this now and I had a pop at using the JLayeredPane, throwing a component to the top which is a MouseListener and KeyListener and consume()s all the events. Works fine for the most part, until there's a JButton within the component - they manage to carry on handling events despite the consuming component over the top of them. Hover over them and they repaint, they're clickable, and so on. Hmm.

  • Working in Logic 9, how do I use a drum loop WITH ITS PRESET EFFECTS? I can drag and drop the loop but it plays dry in timeline. thanks

    Working in Logic 9, how do I use a drum loop WITH ITS PRESET EFFECTS? I can drag and drop the loop but it plays dry in timeline. thanks

    Here's the short-cut solution:
    Green Apple tracks are MIDI files (so to speak). If you drag one from the loop browser (Capitol C Orchestral hit, as you mentioned in this exable) directly into the arrange page it creates the MIDI file and the instrument to play it back on.
    HOWEVER.If you create and audio track first, THEN drag the green Apple loop onto that track, the loop will get "bounced" with the reverb in tact and you'll have the exact sound that you heard in the preview.
    Make sense?

  • How to drag and drop a file with its Systemfile icon to a Jtext area

    I want to drag and drop a file to a JText area with its system file icon , but the problem is I cant show the file icon.
    Anyone knows this.
    this is my code.
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.awt.datatransfer.DataFlavor;
    import java.awt.datatransfer.Transferable;
    import java.awt.dnd.DnDConstants;
    import java.awt.dnd.DropTarget;
    import java.awt.dnd.DropTargetDragEvent;
    import java.awt.dnd.DropTargetDropEvent;
    import java.awt.dnd.DropTargetEvent;
    import java.awt.dnd.DropTargetListener;
    import java.io.File;
    import javax.swing.*;
    import javax.swing.filechooser.FileSystemView;
    public class FileDrag extends JFrame implements DropTargetListener {
    DropTarget dt;
    File file;
    JTextArea ta;
    JLabel lbl;
    Graphics g;
    ImageIcon tmpIcon;
    public FileDrag() {
    super("Drop Test");
    setSize(300, 300);
    getContentPane().add(
    new JLabel("Drop a list from your file chooser here:"),
    BorderLayout.NORTH);
    ta = new JTextArea();
    ta.setBackground(Color.white);
    getContentPane().add(ta);
    dt = new DropTarget(ta, this);
    setVisible(true);
    public void dragEnter(DropTargetDragEvent dtde) {
    System.out.println("Drag Enter");
    public void dragExit(DropTargetEvent dte) {
    System.out.println("Source: " + dte.getSource());
    System.out.println("Drag Exit");
    public void dragOver(DropTargetDragEvent dtde) {
    System.out.println("Drag Over");
    public void dropActionChanged(DropTargetDragEvent dtde) {
    System.out.println("Drop Action Changed");
    public void drop(DropTargetDropEvent dtde) {
    FileSystemView view = FileSystemView.getFileSystemView();
    JLabel testb;
    Icon icon = null;
    Toolkit tk;
    Dimension dim;
    BufferedImage buff = null;
    try {
    Transferable tr = dtde.getTransferable();
    DataFlavor[] flavors = tr.getTransferDataFlavors();
    for (int i = 0; i < flavors.length; i++) {
    System.out.println("Possible flavor: " + flavors.getMimeType());
    if (flavors[i].isFlavorJavaFileListType()) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    ta.setText("Successful file list drop.\n\n");
    java.util.List list = (java.util.List) tr.getTransferData(flavors[i]);
    for (int j = 0; j < list.size(); j++) {
    System.out.println(list.get(j));
    file = (File) list.get(j);
    icon = view.getSystemIcon(file);
    ta.append(list.get(j) + "\n");
    ta.append("\n");
    tk = Toolkit.getDefaultToolkit();
    dim = tk.getBestCursorSize(icon.getIconWidth(), icon.getIconHeight());
    buff = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
    icon.paintIcon(ta, buff.getGraphics(), 10, 10);
    repaint();
    dtde.dropComplete(true);
    return;
    System.out.println("Drop failed: " + dtde);
    dtde.rejectDrop();
    } catch (Exception e) {
    e.printStackTrace();
    dtde.rejectDrop();
    public static void main(String args[]) {
    new FileDrag();

    I want to drag and drop a file to a JText area with its system file icon , but the problem is I cant show the file icon.
    Anyone knows this.
    this is my code.
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.awt.datatransfer.DataFlavor;
    import java.awt.datatransfer.Transferable;
    import java.awt.dnd.DnDConstants;
    import java.awt.dnd.DropTarget;
    import java.awt.dnd.DropTargetDragEvent;
    import java.awt.dnd.DropTargetDropEvent;
    import java.awt.dnd.DropTargetEvent;
    import java.awt.dnd.DropTargetListener;
    import java.io.File;
    import javax.swing.*;
    import javax.swing.filechooser.FileSystemView;
    public class FileDrag extends JFrame implements DropTargetListener {
    DropTarget dt;
    File file;
    JTextArea ta;
    JLabel lbl;
    Graphics g;
    ImageIcon tmpIcon;
    public FileDrag() {
    super("Drop Test");
    setSize(300, 300);
    getContentPane().add(
    new JLabel("Drop a list from your file chooser here:"),
    BorderLayout.NORTH);
    ta = new JTextArea();
    ta.setBackground(Color.white);
    getContentPane().add(ta);
    dt = new DropTarget(ta, this);
    setVisible(true);
    public void dragEnter(DropTargetDragEvent dtde) {
    System.out.println("Drag Enter");
    public void dragExit(DropTargetEvent dte) {
    System.out.println("Source: " + dte.getSource());
    System.out.println("Drag Exit");
    public void dragOver(DropTargetDragEvent dtde) {
    System.out.println("Drag Over");
    public void dropActionChanged(DropTargetDragEvent dtde) {
    System.out.println("Drop Action Changed");
    public void drop(DropTargetDropEvent dtde) {
    FileSystemView view = FileSystemView.getFileSystemView();
    JLabel testb;
    Icon icon = null;
    Toolkit tk;
    Dimension dim;
    BufferedImage buff = null;
    try {
    Transferable tr = dtde.getTransferable();
    DataFlavor[] flavors = tr.getTransferDataFlavors();
    for (int i = 0; i < flavors.length; i++) {
    System.out.println("Possible flavor: " + flavors.getMimeType());
    if (flavors[i].isFlavorJavaFileListType()) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    ta.setText("Successful file list drop.\n\n");
    java.util.List list = (java.util.List) tr.getTransferData(flavors[i]);
    for (int j = 0; j < list.size(); j++) {
    System.out.println(list.get(j));
    file = (File) list.get(j);
    icon = view.getSystemIcon(file);
    ta.append(list.get(j) + "\n");
    ta.append("\n");
    tk = Toolkit.getDefaultToolkit();
    dim = tk.getBestCursorSize(icon.getIconWidth(), icon.getIconHeight());
    buff = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
    icon.paintIcon(ta, buff.getGraphics(), 10, 10);
    repaint();
    dtde.dropComplete(true);
    return;
    System.out.println("Drop failed: " + dtde);
    dtde.rejectDrop();
    } catch (Exception e) {
    e.printStackTrace();
    dtde.rejectDrop();
    public static void main(String args[]) {
    new FileDrag();

Maybe you are looking for

  • Problem with decimal symbol

    When I import in string format and after try to convert to number sometimes my procedure fails. I see that sometimes database need number string decimal symbol to be '.' and I replace ',' with '.' . But time after I find that I must change my procedu

  • Using itunes without a mouse - Keyboard commands

    I have several physically challenged Dragon Dictate (MAC) and Dragon Naturally Speaking (PC)  users asking for custom Dragon commands which will allow them to control iTunes by voice. Has anyone created Dragon macros for iTunes?  Does anyone have a l

  • Details abuout upgration of 4.6B to ECC 6.0

    Hi All, if any one worked on up gradation project, please help me in this. Don't give link to SAP Market Place. 1. What are the steps/procedure to be followed in up gradation? 2. What are the precautionary measures to be taken? 3. How can we do Data

  • Delete site collection using Client object model

    Is it possible to delete a site collection using Client object model? -Prashant

  • Ovi suite 3.1.1.85 software update problem

    Hi! I've got a problem with software update. All the time when I want to make an update ovi displays message "A new software to manage your phone was downloaded, you must reboot your computer". I rebooted it a few times but nothing changes reinstalle