JTree - Trying to make selection a parent select all children

I have a jtree with checkboxes and titles. This is my first semester working with java, I started out in cpp so I'm pretty new to GUIs. I found an example of a Jtree with checkboxes on the leaf nodes online and was able to modify it to have checkboxes on all nodes.
I have been reading through example code of JTrees but have not been able to figure out how to modify children when a parent is modified. If I clicked on an expandable node with sub nodes, I'd want all checkboxes under it to become checked. I've been trying to figure this out for a few days now.
I tried adding a System.out to the getTreeCellEditorComponent class of the cell editor, to see if that's where I'm supposed to put the code (when i figure out what it is) but it gave unexpected output. Clicking a checkbox the first time called the println once, but after that, each click called println multiple times per click. I'm worried that having the extra calls to the code could mess things up. Where would I want to put code for it to be called only once per time the checkbox is clicked?
Oh, I also tried adding a listener to the checkbox in the renderer but it gave really weird results too.
How does the TreePath class work? I tried some stuff with getClosestPathForLocation but couldn't get anything to work.
Thank you very much for your time and help.

Thanks for pointing that out. I had tried a few others but yes his was very close to what I want. I just removed the node icons.
Thanks

Similar Messages

  • Trying to make a payment arrangement

    I've been trying to make a payment arrangement and all customer service reps that I have spoken to are unwilling to help me. I know that I have made many payment arrangements and adjustments but at least I'm paying my bill. They say they cannot make any payment arrangements because I make to many.

    Hi there! @valcorta
    thanks for posting your concerns. You can request a payment arrangement online by the following methods:
    Using your tablet or PC
    Follow these steps for each AT&T service to make a late payment:
    Go to Make a Payment. If prompted, log in1.
    If you manage multiple bills, select the account for which you're making a late payment.
    If you want to split the amount due into two payments with different dates, amounts, and/or payment methods, select Split this Payment.
    Enter the Amount of your payment(s).
    Select the calendar icon, next to the Payment Date field, and choose a date. Available dates are based on your eligibility.
    Select a Payment Method.
    If you select Other, you're committing to paying online, at a payment location, or by phone, on or before the date you selected.
    Enter your payment information, then select Next.
    Review your payment details, then select Submit to complete your scheduled late payment.
    To verify your scheduled payment, go to myAT&T > Billing, Usage, Payments > History tab.
    Using your smartphone
    We make it easy to make a late payment. Just follow these steps for each AT&T service to make a late payment via checking/savings account or debit/credit card:
    Log in from the myAT&T app2 or our mobile site (m.att.com/myatt). If prompted, select your wireless account.
    Select the menu button > Billing & payments, and then select the Make payment button.
    Complete the payment form, including:
    Payment amount
    Payment date - Available dates are based on your eligibility.
    Payment method
    Select Continue, review the Terms and Conditions, and then select Submit.
    To verify your scheduled payment, select the menu button > Billing & payments.
    1myAT&T login - If you don't have a myAT&T login, register today!
    2myAT&T app - Find out how to get the myAT&T app. Compatible device and online account registration required for myAT&T app activation. Data/messaging rates may apply for app download/usage.
    Hope this helps!
    Charise

  • Trying to get this table to "bleed" all the way to the top.., Making a table "bleed" off to the top of browser

    Hi everyone.
    Im new to these forums, and have decided (or more like
    forced..hehe) to use CSS. Now, i am going over the tutorials, but
    have yet to see something that can help me out. (Or my CSS
    understanding needs more understanding). I am trying to make a
    table/div bleed all the way to the top and bottom.. If you take a
    look at this site:
    http://www.helenbwilson.com
    Ok, I want to keep the black background, but I want the white
    to run all the way to the top and bottom-that is, just having black
    to the sides. Can I acheive this, without having to do a complete
    makeover of the site? I am willing to do that, but right now, I
    want to get my friends site up and running, and when one is
    complete, I want to go in and re-do it in CSS (Which i will make
    another topic so I can get help with that..) But for right now, I
    was wondering if there is something I can do about it right now. I
    am using Dreamweaver 8.
    Any help would be greatly appreciated!
    Thanks, and hopefully I will get better at CSS..
    -psypent

    you have to remember what stacks are for, and many people don't.
    they're not designed to categorise and group images. they're designed to group images which are almost identical. for example, when I'm shooting a neighbourhood bird, I'll usually take 10 or more photos of the bird in the same setting with almost the same pose. I'm not sure which photo will have better focus or in which photo the bird's expressions will be better. once back in Aperture, I can group these near-identical photos into a stack and then rank them (I actually prefer to rank them first before stacking). the result is that I only see the best image from that set. if there are other photos in the stack that are different or that I might want to use independently, they'll have to be removed from the stack.
    alternatively but not as ideal, you could view the images in Multi mode, applying ratings and keywords to the images even while they are in stacks. you could then use Smart Albums to get to specific images within stacks by turning on the 'Ignore Stacks' preference at the bottom of the filter HUD.

  • Very new to photoshop I am trying to make changes to a photo and set it up as a smart object but after selecting smart object, the checkerboard appears and my photo dissppears

    Very new to photoshop I am trying to make changes to a photo and set it up as a smart object but after selecting smart object, the checkerboard appears and my photo dissppears

    Hello, thank you so much for your response! Here are some screenshots of my steps taken

  • Error messages when trying to make selection

    Hi, I am new at Photoshop, I use CS6, and today I followed a tutorial on how to make a robot on a picture and at first everything went ok but when I was almost done and tried to make a selection with the lasso tool I all of a sudden got an error message that says "Warning: No pixels are more than 50% selected. The selection edges will not be visible." And when I press OK my selection is not there. I had no problem when I started the project but now it won't work.
    And now I get this error messages everytime I try to make a selection and it doesn't matter if I use the pen, marque or whatever.
    Anyone here who knows what I'm doing wrong?
    Best regards

    Basically, what that warning message is telling you is that the "marching ants," will not be fully representative of your Selection.
    Now, if you want to make a Selection, that includes 100% of the pixels, check the Lasso Options, to make sure that you do not have something like a large Feather, with a small Selection.
    Good luck,
    Hunt

  • Can you add audio tracks as selectable menu items on a dvd? I shot a wedding where the church had its own set up to record audio. I'm trying to make those songs performed by the artists available for viewers of the dvd to select for listening.?

    I'm trying to make audio (MP3) tracks available for viewers of this Wedding dvd to select for listening. Is this possible in iDVD?

    You will need to create a slide show for each of those songs with a minimum of 1 photo per slideshow and add the song to the slideshow audio bin. Set the audio to Fit to Music.
    In your top/main menu add a submenu for the list of songs.
    Add a slideshow for each song with the "+" button at the bottom:
    Select the link in the menu and rename it for the song used in the slideshow.  You can create a slide image for each song with the song name, composer, singer, etc. on the image to be used for the slideshow  An image editor or Pages can be used for that and then convert to a jpeg file for use in iDVD.
    The song/playlist menu could look like this depending on the theme you choose:
    OT

  • When trying to make a purchase for a movie I get a security information required field then I select continue and it brings me back to original screen to purchase movie. Please help.

    When trying to make a purchase for a movie I get a security information required field then I select continue and it brings me back to original screen to purchase movie. Please help.

    It's telling you to verify your billing information (credit card, address, security code), which needs to be done in iTunes via computer.

  • I am trying to make a second website in iweb, I click 'new site' and select the site style, but it keeps opening my existing website.  Any ideas?

    I am trying to make a second website in iWeb.  I have clicked 'new site' and then selected a style for the website, but then my existing website opens instead of a new one.  Any ideas how to fix this?

    Do you not get a new site folder at the left under your existing site?
    OT

  • I'm trying to make a AUTO slide show. I can select all the other actions like mouse clicks etc. but

    I'm trying to make a AUTO slide show. I can select all the other actions like mouse clicks etc. but ON load will not work.
    PLEASE HELP>
    I do not know how to reload/reinstall "ADOBE" golive default actions. I'm using golive cs mac version and "ON LOAD" action. I can't select it when creating a golive action.....It converts it or something to a rollover..
    How can I reistall basic adobe actions???
    Is it a bug???
    Is it a known issue???
    Do I need something??
    Am I missing something???
    Thanks a bunch..
    Kev

    In article <[email protected]>,
    [email protected] wrote:
    > I do not know how to insert the auto slideshowaction as a head action item.
    > The steps.
    > Can you explain how to do it?
    I just remembered I have a couple of screen snaps online to explain how
    it's done:
    1. place your base image and name it in the inspector
    2. from the smart objects palette grab the head action item, the one
    with a question mark in its upper, green half - the 2nd one from the
    left. Drop that into the pages head section.
    3. in the inspector set the action to run OnLoad and select the base
    image that you named in the first step and set the other parameters.
    This was done in the days of GL6, but not much had changed in GL CS.
    Anyway you might also refer to GL's online help. It describes how to set
    up all the actions that ship with GL.
    Cheers Martin

  • How to show only all children of selected node in JTree??

    Dear friends:
    I have Two Panels, PA and PB,
    PA has a Jtree as code below, and PB listens to PA,
    I hope to do following,
    If I select a node called A in PA, then Node A's all children such as A1, A2, A3 will be displayed in PB, but not display A1, A2, A3's children such as A3 has C1, C2, C3, C4 & C5, until I select A3 then PB will display only all A3's children: C1, C2, C3, C4 & C5;
    i.e, only populate each ONE level of children of Node A or any node I select, not its grandchildren and its grand-grand children;
    Please help how to do it??
    I tried amny times, failed.
    Thanks
    [1]. PA panel code:
    package com.atest;
         import java.awt.BorderLayout;
         import java.awt.event.MouseAdapter;
         import java.awt.event.MouseEvent;
         import java.util.Enumeration;
         import java.awt.Dimension;
         import javax.swing.JFrame;
         import javax.swing.JPanel;
         import javax.swing.JScrollPane;
         import javax.swing.JTextField;
         import javax.swing.JTree;
         import javax.swing.tree.DefaultMutableTreeNode;
         import javax.swing.tree.TreeModel;
         import javax.swing.tree.TreePath;
         public class DefaultMutableTreeMain extends JPanel {
         protected DefaultMutableTreeNode    top = new DefaultMutableTreeNode("Options");
         protected DefaultMutableTreeNode      selectedNode = null;
         protected final JTree tree;
         protected final JTextField jtf;
        protected Enumeration      vEnum = null;
         private      TreeModel                m;
         protected  DefaultMutableTreeNode      getDefaultMutableTreeNode()  {
              //textArea.getText();
                   return selectedNode;
         protected  DefaultMutableTreeNode setDefaultMutableTreeNode(DefaultMutableTreeNode tt)  {
              //textArea.getText();
                   selectedNode = tt;
                   return selectedNode;
         protected  TreeModel getJTModel()  {
              //textArea.getText();
                   return m;
         protected  TreeModel setJTModel(TreeModel ta)  {
                   m = ta;
                   return m;
           public DefaultMutableTreeMain() {
             setSize(300,300);
             setLayout(new BorderLayout());
             DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
             top.add(a);
             DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("A1");
             a.add(a1);
             DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("A2");
             a.add(a2);
             DefaultMutableTreeNode a3 = new DefaultMutableTreeNode("A3");
             a.add(a3);
             DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
             top.add(b);
             DefaultMutableTreeNode b1 = new DefaultMutableTreeNode("B1");
             b.add(b1);
             DefaultMutableTreeNode b2 = new DefaultMutableTreeNode("B2");
             b.add(b2);
             DefaultMutableTreeNode b3 = new DefaultMutableTreeNode("B3");
             b.add(b3);
             DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");
             a3.add(c);
             DefaultMutableTreeNode c1 = new DefaultMutableTreeNode("C1");
             c.add(c1);
             DefaultMutableTreeNode c2 = new DefaultMutableTreeNode("C2");
             c.add(c2);
             DefaultMutableTreeNode c3 = new DefaultMutableTreeNode("C3");
             c.add(c3);
             DefaultMutableTreeNode c4 = new DefaultMutableTreeNode("C4");
             c.add(c4);
             DefaultMutableTreeNode c5 = new DefaultMutableTreeNode("C5");
             c.add(c5);
             tree = new JTree(top);
             JScrollPane jsp = new JScrollPane(tree);
             jsp.setPreferredSize(new Dimension(400,300));
             add(jsp, BorderLayout.CENTER);
             jtf = new JTextField("", 20);
             add(jtf, BorderLayout.SOUTH);
               tree.addMouseListener(new MouseAdapter() {
               public void mouseClicked(MouseEvent me) {
                  TreePath   path = tree.getSelectionPath();
                  DefaultMutableTreeNode      selectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
                 TreePath tp = tree.getPathForLocation(me.getX(), me.getY());
                 setDefaultMutableTreeNode(selectedNode);
                     System.out.println("Current node selected is (tp.toString()=" + tp.toString());
                     System.out.println("Current node selected is getDefaultMutableTreeNode()=" + getDefaultMutableTreeNode());
                 if (tp != null){
                     jtf.setText(tp.toString());
                      System.out.println("It Has Children as selectedNode.getChildCount()= " + selectedNode.getChildCount());
                            Enumeration vEnum = selectedNode.children();
                                int i = 0;
                                while(vEnum.hasMoreElements()){
                                    System.out.println("2 selectedNode = " +  path.toString() + "  has " + i++ + " Children in vEnum.nextElement(" + i + ") = " + vEnum.nextElement());
                 else
                   jtf.setText("");
           public static void main(String[] args) {
             JFrame frame = new JFrame();
             frame.getContentPane().add(new DefaultMutableTreeMain());
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setSize(400, 400);
             frame.setVisible(true);
         }[2]. PB Panel code
    package com.atest;
    import java.awt.BorderLayout;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    import javax.swing.JPanel;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.*;
    import javax.swing.JButton;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreePath;
    public class DefaultMutableTreeSub extends JPanel implements java.io.Serializable{
      private JButton removeButton;
      private JButton addButton;
      JTree tree;
      private TreeModel      m;
      protected TreeDragSource ds;
      protected TreeDropTarget dt;
    protected  TreeModel getJTModel()  {
              //textArea.getText();
                   return m;
    protected  TreeModel setJTModel(TreeModel ta)  {
                   m = ta;
                   return m;
    protected DefaultTreeModel model;
    protected DefaultMutableTreeNode rootNode;
    DefaultMutableTreeMain dmm = null;
    JPanel inputPanel  = new JPanel();
      public JPanel SLTreeDNDEditableDynamic(DefaultMutableTreeMain tdnd ) {
        //super("Rearrangeable Tree");
        setSize(400,450);
        dmm = tdnd;
             setLayout(new BorderLayout());
             inputPanel.setLayout(new BorderLayout());
             JPanel outputPanel = new JPanel();
             System.out.println("Sub selectedNode tdnd= " + tdnd);
             tdnd.tree.addTreeSelectionListener(new TreeSelectionListener(){
                  public void valueChanged(TreeSelectionEvent evt){
                  TreePath[] paths = evt.getPaths();
                  TreePath   path = dmm.tree.getSelectionPath();
                  DefaultMutableTreeNode      selectedNode = (DefaultMutableTreeNode)path.getLastPathComponent();
                 DefaultMutableTreeNode itemNode = dmm.getDefaultMutableTreeNode();
                     System.out.println("Sub node selected is dmm.getDefaultMutableTreeNode()=" + dmm.getDefaultMutableTreeNode());
                  model = new DefaultTreeModel(itemNode);
                  tree = new JTree(model);
                  System.out.println("Sub selectedNode paths= " + paths);
                  System.out.println("Sub selectedNode path= " + path);
                  System.out.println("Sub selectedNode = " + selectedNode);
                  System.out.println("Sub itemNode = " + itemNode);
                  tree.putClientProperty("JTree.lineStyle", "Angled");
                  tree.setRootVisible(true);
                   inputPanel.add(new JScrollPane(tree),BorderLayout.CENTER);
             return inputPanel;
         public DefaultMutableTreeSub() {
              super();
    }thanks
    sunny

    Thanks so much, I use your code and import followig:
    import java.util.ArrayList;
    import java.awt.List;
    but
    private static List<Object> getChildNodes(JTree j) {
         Object parent = j.getLastSelectedPathComponent();
         int childNodeCount = j.getModel().getChildCount(parent);
         List<Object> results = new ArrayList()<Object>;
         for (i = 0; i < childNodeCount; i++) {
              results.add(parent, i);
         return results;
    here List<Object> and ArrayList()<Object> show red,
    Is my JDK version problem??
    my one is JKD
    C:\temp\swing>java -version
    java version "1.4.2_08"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
    Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
    Error as follows:
    C:\temp\swing>javac DefaultMutableTreeSub.java
    DefaultMutableTreeSub.java:38: <identifier> expected
    private static List<Object> getChildNodes(JTree j) {
    ^
    1 error
    any idea??
    Thanks

  • Tolerance dialogue missing on "make work path from selection"

    I am trying to convert a 1-color drawing to a path so I can put it into Illustrator. I use the magic wand to select the edges and get a nice tight fit. But when I select the "Make work path from selection" button, I get a sloppy fit. I've looked this up, and supposedly I should get a dialogue box asking me to state the tolerance. I have never seen that box - I've tried it and had colleagues come try it. My version 13.1.2 x64. Seems like a bug to me, but maybe I'm missing something. Is there another way to do this? Thank.s

    R_Kelly wrote:
    If you press the Alt/Option key while pressing the Make work path from selection button, then you'll get the Tolerance dialog.
    Other ways are to right click inside the selection and choose Make Work Path or use the flyout menu from the Paths panel and choose Make Work Path.
    Hah!  I didn't know that RK
    [EDIT]  As an aside to the above information, having had a play with it, I have realised how poorly the 'Make work path from selection' feature works in Photoshop.  It has always worried me that distibution of points that result from using that feature on a Shift drag eliptical marquee circle, appear less than optimal, but I have just lived with that because it is quick and convenient.  But having just looked again, zooming right in and activating the point handles, the curve is just plain horrible!
    Me thinks I shall take the time to do it properly in future, by using the Shape tool.
    It also amazed me how many points were used when setting tolerance to the minimum of .5
    Anyway...  I am not getting my work done here, so time to earn a living

  • Could not make a new layer from the selection because the selected area is empty

    I have Photoshop CS5 and I'm trying to do a selection on a new layer and when I copy it this message appears: "could not make a new layer from the selection because the selected area is empty"..
    The new layer is selected, no other layer is selected. What the hell am I doing wrong???....Yes I'm a beginner.. ....please help?

    Hi There,
    So just to clarify you have made a new blank layer, made a selection on that layer and then done a Layer > New > Layer via Copy (or cmd J).
    The reason that you would get this error message is you have made a selection on a blank layer (effectively selecting nothing) and tried to duplicate it and Photoshop won't let you do that.
    When doing New Layer via Copy or New Layer via cut you selection needs to include some painted (coloured) pixels.
    Regards
    Paul
    PS. Maybe you could explain what you are trying to achieve by copying the layer and I could help a little more.

  • I really need someone to help me. I have been trying to figure out how to select a PDF document to convert to a Word doc. When I go to select a PDF file, all that shows up is the WORD docs. does not show ANY of my PDF files... Please help me figure out wh

    I really need someone to help me. I have been trying to figure out how to select a PDF document to convert to a Word doc. When I go to select a PDF file, all that shows up is the WORD docs. does not show ANY of my PDF files... Please help me figure out what is going on? We have it set on auto renewal so I know its not that we haven't renewed this subscription, because we pay automatically.

    Hi olivias,
    It sounds like there may be some confusion on your system about what application should be associated with PDF files. You can reset filename associations by following the steps in these articles (depending on your operating system):
    How to change the default application for a file type | Macworld
    http://windows.microsoft.com/en-us/windows/change-default-programs#1TC=windows-7
    Please let us know if you have additional questions.
    Best,
    Sara

  • How to make changes on the selection screen of a logic database?

    I want to make one of the select-options of logic database PNP no-interval no-extension, what should I do? Is there any links for manipulating LDB? thx~

    Hi,
    This blog on SDN will help you on this.
    [Re: Change selection screen in LDB (KDF logical database - NOT HR);
    Regards
    Abhii....

  • How can I use an image as a button and make it invisible unless selected?

    Hello,
    I have been trying to use this button I created in Photoshop in Encore but I cannot get it to work the way it should.  First I import the image and drag it onto my menu.  Then I select "Object" then "Covert to button".  That creates a button but I want it to be invisible unless I select it.  Creating a button this way only overlays colors on top of the image when selected vs not selected.
    What I need is to have the image been a subpicture highlight.  I tried to use Photoshop to create a layer under my buttons and use the image there, typing (=2) as the layer name.  I think this is supposed to show the button in its selected state?
    But that doesn't work.  The image is invisible when I open the menu in Encore, not matter what I select for button highlights.
    Could you please explain how to create an invisible button but use an image as its selected state and possibly another for its activated state?
    Thanks.

    Have you tried using the selections in the Encore menu viewer that show you selected and activated states?

Maybe you are looking for

  • How can I use Find my iPhone on supervised devices?

    I manage a fleet of iPad 2 carts for my school all using the same Apple ID, but I have run into a wall with this problem. In the past Find my iPhone has not be able to for me on supervised devices. I have thought about using Meraki, but I have read t

  • URL to run a report file that is not located in $ORACLE_HOME/reports dir

    All, I know very little about configuring reports on the web. We have had a 10g App Server running for several years. All of our reports files so far have been located in the Middle Tier's $ORACLE_HOME/reports directory. We now have a need to create

  • Early 2009 Mac Pro CPU upgrade

    Hello all I just purchased a 2009 2.66 quad core Mac Pro. I am wondering if the CPU is upgradable. Since the new CPU sits on a slide out tray and shares the same CPU socket as the 8 core CPUs. Can a user upgrade the CPU later? Say if I want to upgrad

  • ViewRow Method Action VS. ApplicationModule Method action in a Taskflow

    Hello all, I have a method on my ViewRow which i dropped in my TaskFlow, whenever it was called i got a NoSuchElemenException. I created a method in my application module which calls the method on the ViewRow:           MyViewRow vCurrentRow = (MyVie

  • Sales Order to Production Order Value

    Hi Without using a BOM can I enter a manual value in to Sales Order (VA02) conditions (e.g. EK01/2) and have the value push to the production order value/COGM (CO03). Thanks