Does an irrepariable "Invalid B-tree node" = unusable HD?

Hello,
I've decided my external LaCie drive has officially "died," but I want to know if it's truly unuseable or if I can just reformat it and start over (with it) again.
The Drive: a LaCie 300GB with one 40GB scratch partition and one 260GB backup partition.
What happened: After a about a week of erratic/slow disk access to the backup partiton (I'd shrugged it off as a full and fragmented drive), it finally just screeched to a snail's pace - so I could read/write to it, but, for example, copying 5MB file to/from it took about 3mins. I quickly backed up as much as I could off of it to another drive (100GB took 14hrs) and just as it finished copying the last file, it disappeared from my sidebar (though the scratch partition was still visible). I Disk Utility and could see it was unmounted and it's "name" had been reset to "disk5s3". Running the First Aid repair resulted in a quick "Invalid B-tree node size" ... "Error: The underlying task reported failure on exit".
Flash forward three days later: After unsuccessfully running Disk Warrior and Data Rescue for 20hrs (progress estimated it would take 400hrs to complete scan) - I gave up.
Sorry for the long setup, but my question is: can I just "zero" the drive and use it again, or is it "damaged" physically and suitable for a paperweight only. If it's usuable after reformatting, is there a way to test the hardware of the drive to assure it's stable?
Thanks for your time!

can I just "zero" the drive and use it again, or is it "damaged" physically and suitable for a paperweight only
Like Dwight I doubt the drive is physically damaged but simply has a damaged catalogue b-tree. The only way you're going to find out though it to erase the drive and write zeros to it. Just be aware that everything on the drive will be lost (though I gather you know that already) if you do this.

Similar Messages

  • Invalid B-tree node size error & updating OS

    I was toying around with the idea of updating my OS to 10.4 and increasing my storage capacity. A welcome upgrade to an old system that has been very good to me....until now.
    The short version is that I am experiencing quite a bit of directory damage (for the full story, read below). After researching hundreds of posts here, I think my best bet is to purchase Disk Warrior. My question is, which version should a purchase? As a result of the work I've explained below, my system is currently running the version installed from my OSX Install CD. I'm not sure what version this is, but my Mac came with CDs for OS9, OSX, and an upgrade to 10.2.8. Is there a version of Disk Warrior that will support 10.2-10.4? I want to fix the current issues but still be able to use this software when (or IF) I upgrade.
    I'm happy to provide any info needed and appreciate ANY help. Thanks,
    On a routine startup I encountered the stalled progress indicator (spinning gear) and its been downhill from there. I've scoured the Mac forums here for possible fixes, but so far nothing has been able to completely solve my problem. Here's a brief rundown of what I have done so far:
    1) Booted from OSX Install CD and ran disk utility. This verified I had catalog and node errors that could not be repaired.
    2) Ran Apple Hardware test from CD. Everything was fine.
    3) Ran TECHTool Pro that came with my AppleCare CD and identified similar errors but could not repair them. At this point I also got an "Invalid Sibling Link" error.
    Finally I decided that the data I had saved on my HD was not crucial so I would attempt a reinstall of the OS and lose what was not backed up. So I:
    5) Performed reinstall from OSX Install CD.
    6) Ran Disk Utility, all was fine.
    At this point I was able to run programs and boot up normally. Of course this was too good to be true, and it was, because subsequent restarts gave me even more errors! I was again experiencing the freeze at startup, although this time I was getting the Mac computer logo with smiley face icon for all eternity.
    7) Again booted from OSX Install CD and ran Disk Utility. I'm now getting an "Invalid B-tree node size" error. I;ve tried all the cycles with repair utilities to no avail. I am also unable to start up in single user mode so I'm stuck.
    iMac G4 Flat Panel   Mac OS X (10.2.x)   Purchased 2002
    iMac G4 Flat Panel   Mac OS X (10.2.x)   Purchased 2002

    Thanks! I will order DW and give it a try...
    I have run the Apple Hardware diagnostic CD twice (at different points in this process) and everything has come back cleanly. I am fairly certain this is a directory issue, but we'll wait and see. At the very least I will have DW to back up any future systems.
    This is sortof off topic, but what is the general service fee for visiting the Genius Bar? I consulted a Mac pro there to discuss an upgrade to my system, but there was no charge. I find this hard to believe...does anyone know? I can't seem to find anything online...

  • Invalid B-tree node size (3,0) error - what is it??

    Yesterday I had a HDD issue on my iMac (OSX 10.5) with an 'invalid node structure' error. I eventually managed to boot into 'single user mode' and used #fsck_hfs -rf /dev/disk0s2 at the command prompt. This got OSX up and running properly again. I then repaired the permissions and the disk using the disk repair utility.
    Today, I have had a complete system freeze which necessitated a cold reboot. Since then nothing has worked. I can't boot in safe mode, single user mode or verbose mode. I tried resetting the PRAM and attempted to boot from a system install disk without initial success. After about half an hour the disk icon appeared on the screen and I could boot from the install disk. I then used the terminal to try 'fsck_hfs -rf' again. This time I got the error 'Invalid B-tree node size (3,0)'. What does this mean and what do I do now?? Most forums seem to suggest using 'Disk Warrior'. Since this costs about $170 in Australia I am unlikely to take this option. Having been unemployed for more than 5 months I am more likely to attempt replacing the drive myself. However, I'd prefer to take another approach if there is one. Any suggestions?? Would it be better to give up on replacing the internal drive and try for a bootable external HDD? Too slow?

    HI and Welcome to Apple Discussions...
    Check out TechToolPro but they might be even more $$$.
    Unfortunately, it takes a robust disk utility to repair an invalid tree node. Your best bet really is DiskWarrior
    *"Would it be better to give up on replacing the internal drive and try for a bootable external HDD? Too slow? "*
    You could use a bootable external drive but there again you are looking at an investment.
    Carolyn
    Message was edited by: Carolyn Samit

  • Invalid B-tree node size

    So I used techtool 4 to try to improve my performance. There weren't any problems before, but I figured "Hey, I might as well." Suddenly both drives disappeared and techtool 4 told me they aren't there. I tried Disk Utility, but it gave me the error message "Invalid B-tree node size." I have no idea what that means and I have some extremely valuable information on that drive that I haven't backed up yet. I don't have $100 to throw away on Disk Warrior either. Is there any other solution that I can do to fix this problem that techtool 4 seemed to have caused.

    You analyzed it with Disk Utility but it won't mount? Did you try to mount it with Disk Utility?
    Try using an application such as [Data Rescue II|http://www.prosofteng.com/products/data_rescue.php] or [FileSalvage|http://subrosasoft.com/OSXSoftware/index.php?mainpage=product_info&productsid=1]. Both have free trial versions that let you see if the software will help before you decide to buy. You will also need a second hard drive equal to or larger in size than your first drive.
    There is also this free tool which supposedly runs on OSX and does recovery of popular media and Office files. http://www.cgsecurity.org/wiki/TestDisk_Download
    I have not seen any reports from anybody who has actually used this tool and the documentation is not terribly clear so it really is an unknown as far as I am concerned.

  • How can you repair "invalid node structure and invalid b-tree node size"

    I have a MacBook Pro 17"  and the original install disk is Mac OS 10.4.  I have an update 10.6 install CD, but I cannot use it to boot up my computer.  My computer had been running on 10.6 when the problem occurred.
    It seems my harddrive has crashed. It only boots to apple logo and spins.  I have reset the pram. Started up in safe mode with shift pressed down and started up on the start up disk,  where I did repair disk and got this "invalid node structure invalid b-tree node size".  Then it said repair failed to complete.  I tried booting again but it still failed. I thought doing a restore might solve the problem.  I have a month old backup with time machine which is on a lacie external drive, but when I try to restore using my original 10.4 install disk, I can only choose the lacie hardrive icon (by dragging) and cannot choose the folder in the backups with the latest backup.  When I tried to restore, it says my source is not a valid option.  Is this because it is a 10.4 startup disk.
    Basically I have two questions:  Is there a way to fix my problem without doing a restore and if I have to restore, how do I restore my time machine backup?  Will I need to do a reinstall with 10.4 and then update to 10.6?
    I really hope to find a way to have my computer back to how it was when it started spinning and if not, at least as it was when I did the latest backup 3 weeks ago. 
    Please help me!!! 
    Rebecca

    You should be able to boot to the Snow Leopard upgrade disc — you had to do so to install the upgrade in the first place. If you can't boot to it now, either the disc is scratched or dirty or your drive's lens is dirty; for the latter problem, a drive cleaning disc is an inexpensive, frequently-used and often successful remedy, available at any store that sells DVDs.
    Because you're running Snow Leopard now, you should repair your hard drive directory using the Snow Leopard version of Disk Utility, not the one on your Tiger installer disc. If you aren't able to do so even after trying to clean your drive, you could buy and use DiskWarrior to rebuiild the damaged HD directory. But DW costs nearly $100, and though it would probably do the trick, that's a bunch of money. You'll have to weigh its cost against the value of the new or changed data on your drive that hasn't been backed up in the last three weeks. If you can get along without that data, then erasing your hard drive and restoring from your last backup is the no-cost, immediate (as opposed to waiting for a DW startup disk to arrive in the mail) solution.

  • Volume won't boot: Invalid B-tree node size

    My OS 10.4 volume on a G4 tower will no longer boot (I can mount it from another volume on the same machine, though).
    The problem started with trying to read from a damaged CD. I powered-off the machine when it hung trying to copy a file. After I could no longer boot. Disk utility said bad leaf record count (I think). The utility could not do the repair, fsck didn't help.
    I have a copy of Techtool deluxe (that came with a Tiger-loaded G5). I ran that. It found, and claimed to have repaired, the problems (though it took a looong time). Techtool now finds no errors.
    However, I still cannot boot. Running diskutility get me:
    Invalid B-tree node size
    Error: the underlying task reported failure on exit (-9972)
    Trying to boot in single-user mode gets a nasty panic.
    I guess my question is: Is it worth trying to run another repair utility? If Techtool thinks everything is OK, is there any point doing more? Did I mess this up by using the Techtool that came with a G5 on my G4? (not sure I want the answer to that last question.)
    Thanks for any pointers.
    g4 tower   Mac OS X (10.4.3)  

    Thanks for the tips. I could have swornTechtool deluxe came with machines loaded with Tiger, but I guess not.
    Before I messed things too badly with Techtool delux I made an image of the volume. It still has the bad leaf count, but at least it could mount.
    I'm going to erase the volume, reinstall the system software and then copy all my files off the diskimage. One more question: If I want to copy applications from the diskimage should I copy anything besides the stuff in the Applications folder? something from the Library?
    Thanks again.

  • Is my hard drive dead? Invalid B-Tree Node Size

    When I turn on my powerbook it goes to the grey screen with the apple in the middle comes up and then it goes to loading Mac OS X which I am trying to do but when it comes to Select a Destination my hard drive is not listed. I click on utilities and go to utilities and disk utility. My hard drive is listed on the left side so i click it. I then click verify disk and it sais Invalid B-Tree Node Size and Volume needs repair. Then I click repair but the same thing comes up. What can I do? PS-I did a search but none of the info I came up with helped me at all.

    they are about $100 and available from most Apple dealers:
    http://alsoft.com/DiskWarrior/index.html
    http://www.micromat.com/
    if there are no important files on the drive, erasing the drive and reinstalling OS could possibly fix it unless it's caused by failing drive hardware.
    if erase/install does not work properly, could be bad drive.
    "B-Tree" message could simply be caused by messed up files and there is nothing wrong with the drive itself.

  • Invalid b-tree node and the disk can't be repaired.  Is it worth the reformat or is the hard drive trashed?  This is a Mac mini, I've had it since 2010 and already had to replace the hard drive once.

    Swapped out the monitor on my Mac mini tonight and it wouldn't start back up.  Managed to boot off the install disk and run disk utility, which gave the invalid b tree node error.  Wasn't able to repair the disk, suggested a reformat.  Is this worth my time?  Or is the disk toasted?  I got it in 2010, it's out of warranty and has already had the hard drive replaced once.  Thanks!
    -laura

    If you want to save the data from the drive, Phoenix might be able to copy (clone) it off on another volume. You can check it out at:
    http://scsc-online.com/Phoenix.html
    Phoenix does a file copying cloning, not block copy cloning, so a new index is generated on the drive when the copy is being made. If none of the files got lost, meaning just the index is screwed up, I would think this would work.
    Regarding the hard drive an index problem isn't a hard drive problem. That hard drive may be in perfect working order, especially since it's fairly new.

  • Invalid B-tree node and disk stuck

    Last night my 2 year old iMac froze up. When I re-started I received the flashing question-mark folder. I ended up inserting my OS X install disk and attempting to run the Disk Utility. I tried to repair the disk, but got the "Invalid B-tree node size" error with "The volume needs to be repaired."
    I have tried a lot of things and will probably end up buying Disk Warrior and hoping that fixes it. BUT, I have another problem. I can't eject the OS X install disk. The option to eject is greyed out on the Disk Utility, the eject key doesn't work, and I can't find any way to unload the disk. Help would be appreciated.

    If you have an external hard drive it would be easier to clone your system to the external then boot to the external and run Disk Warrior from there. However if your system won't boot in the first place that won't work. You could pick up a copy of Disk Warrior from the Apple store.
    http://www.bombich.com/software/ccc.html
    George

  • Receiving Invalid B-tree node size in Disk Utility

    My mac mini has recently bit the dust.  I did a hard shut down by holding down the power button.  Since then I have not been able to bring it back.  It started with a folder with a ? in it.  Sometimes it sits at the apple logo, and other times it goes to a gray screen and just reboots eventually.  I am running Snow Leopard, and I have booted from the install cd.  I have tried running Repair Disk in Disk Utility, but I receive the following error:  "Invalid node structure Invalid B-tree node size The volume could not be verified completely.  Volume repair complete.  Updating boot support partitions for the volume as required.  Error:  Disk Utility can't repair this disk...disk, and restore your backed-up files."
    In the pop up window it says "Disk Utility stopped repairing "macintosh HD" Disk Utility can't repair this disk.  Back up as many of your files as possible, reformat the disk, and restore your backed-up files.  On the left hand side of the window I see 60.01GB ST96812AS Media, and then I see Macintosh HD offset underneath.  The Macintosh HD is in light gray and is not mounted.  When I try to Mount it it gives me an error and tells me to repair the disk. 
    My question is do you think Disk Warrior would work or something like that software?  I tried to do an Archive and Install, but since the HD won't mount I can't do an installation.  Is my HD dead?
    Any help would be appreciated!
    Sincerely,
    Matt

    As you can see, I received no help from this forum.  I ended up replacing the hard drive after trying disk warrior unsuccessfully!  I wish you luck and anyone else who has this issue.
    <a href="http://www.medicare-plans.net">Medicare Man</a>

  • Invalid B tree node size- Computer won't start up anymore

    Get the kernel panic/restart messsage - when I restart same thing.... Tried all of the solutions Apple suggest- re-setting PRAM, holding the "X" key, holding the "option" key... nothing seems to work. Ran the OSX install CD and went to utilites, tried to repair the disk that way- but get the message- " Invalid B Tree node size, volume check failed. Error: The underlying task reported failure on exit. IHFS Volume checked - Volume could not be repaired beause of an error.
    CD would also not let me re- install OS X
    Currently using OS X 10.4.9 on a G4 iMac

    Owen:
    Thank you for posting back with an update of your situation. I am glad you were able to work your way through your issues and secure your Users Folder. Data Resuce II is a great tool.
    I have been using different versions of TechTool Pro since OS 9 and have found it to be a great tool. It has saved me from disaster several times. I use TechTool Pro 4.5.2 on Tiger. I am not sure what version you were using, but if, indeed, TTP damaged your data, and I have serious doubts about that, it could be that you were using the wrong version.
    Having a good backup strategy is very important. You will find some good hints in Dr. Smoke's FAQ Backup and Recovery. My main difference with Dr. Smoke is the he insists on using Retrospect as his backup software, whereas I have never been able to get it to work. Besides, you will find that SuperDuper is much friendlier and efficient. Indeed, SuperDuper was rated the best backup software in tests. And no need to wait for Leopard to do scheduled backups. SuperDuper will do that, too.
    Again, I am glad your issue has been resolved. Use Disk Warrior regularly to rebuild your directories and follow a regular maintenance schedule such as the one Gulliver suggests in his article Mac OS X System Maintenance.
    Happy Mac Computing.
    cornelius
    Message was edited by: cornelius

  • 'Invalid node structure', 'Invalid B-tree node size', Disk Warrior useless

    Hi everyone, I am getting sick of this, it's the second time it's happened to me in a relatively short space of time, the first time with an Iomega external 500GB drive, this time with a 1.5TB Western Digital.
    I gave the Western Digital drive two partitions, (as I did for the previous Iomega drive), one for doing backups of my MacBooks internal drive, the other for random media, mostly VIDEO_TS folders.
    After going away for a couple of weeks, I returned home, plugged in the Western Digital drive via USB, the Internal backup partition showed in Finder, the other did not. Obviously I ran Disk Utility which was only able to show an error report with the usual 'Invalid node structure etc' message.
    I tried running Disk Warrior 4.2 (supposedly the version which works with Snow Leopard) from the DVD, (holding down the C key after restart), and..... nothing, just the grey screen and spinning wheel showing, so I gave up on that and installed DW to the Utilities folder. Now it starts up, the corrupt drive showed up, I hit the Rebuild button in DW, things seemed to be happening, but then the Beach Ball appeared and there was a (very) long hang before I decided to Force Quit.
    I am assuming that if DW can not fix the drive, it is done for, and may as well be used as a door stop.
    I am prepared to buy yet another drive, but can someone please give me an idea about why this has happened to me twice now, and what I can do to prevent it from happening again?

    Just erase the partition. Nothing yet suggests the drive is bad. When you got the drive did you prep it correctly? Usually bare drives are pre-formatted for Windows. You might consider doing this:
    Extended Hard Drive Preparation
    1. Open Disk Utility in your Utilities folder.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to two and size them as you prefer. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID then click on the OK button. Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    Repeat Steps 4-6 for the other partition. Alternatively, you can start with a single volume. After the zero data erase you can then re-partition the drive.

  • Powerbook G4 10.4.11  won't start from hard drive .  Tried repair, " The underlying task reported failure on exit (-9972).Invalid sibling link,invalid B tree header, invalid map node,invalid record type,the volume needs to be repaired.

    Powerbook G4 10.4.11  won't start from hard drive .  Tried repair, " Invalid sibling link,invalid B tree header, invalid map node,invalid record type,the volume needs to be repaired.Powerbook G4 10.4.11  won't start from hard drive .  Tried repair, " The underlying task reported failure on exit (-9972).Invalid sibling link,invalid B tree header, invalid map node,invalid record type,the volume needs to be repaired.
    The underlying task reported failure on exit (-9972).

    kauribill wrote:
    " The underlying task reported failure on exit (-9972).Invalid sibling link,invalid B tree header, invalid map node,invalid record type,the volume needs to be repaired.
    The underlying task reported failure on exit (-9972).
    This is a directory issue that Disk Utility cannot fix. Although it manifests itself as a software issue sometimes it may be hardware based. See DiskUtility reports "Underlying task reported failure" when repairing avolume http://support.apple.com/kb/TS1901?viewlocale=en_US". You can try using a utility like TechTool Pro, Drive Genius or Disk Warrior to repair and replace the directory. Another option would be to use the Archive and Install feature to reinstall. If the problem returns after correction you may have a failing or failed HDD.
    cornelius

  • Useful Code of the Day:  Hideable Tree Nodes

    Someone posted about how they could selectively hide tree nodes, and I already had this AbstractTreeModel class (which does some things DefaultTreeModel does and some it doesn't) and a concrete subclass for TreeNode objects, so I was thinking how one could do hideable nodes. So I came up with this solution.
    There's 4 classes here:
    - AbstractTreeModel is the base for the concrete TreeNodeTreeModel
    - TreeNodeTreeModel extends AbstractTreeModel to support TreeNodes (DefautlMutableTreeNode, etc.)
    - HideableMutableTreeNode which is a DefautlMutableTreeNode subclass which has a visible field (with is/set methods, of course).
    - HideableTreeModel is the hideable model which is a subclass of TreeNodeTreeModel.
    A HideableMutableTreeNode can be set invisible directly, but the tree still needs to be notified to update. So it's best to use the methods in HideableTreeModel which set a node's visibility which notify the tree of changes accordingly. Methods are also provided to check a full path's visibility or ensure a node including all parent nodes are visible.
    A HideableTreeModel can take any TreeNode class, it doesn't have to be all HideableMutableTreeNodes, but only HideableMutableTreeNodes can be made invisible, of course. Any other TreeNode type would just be considered visible.
    Hiding nodes works basically by making the tree think there's less nodes then there are. And to do this, the node counts and child index search just works by looping thru the parent's children. This has potential perfomance drawbacks of course, since one has to loop thru the node's children to get nodes every time. This could be alleviated by not supporting non-hideable nodes changing the internal maintenance of HideableMutableTreeNode contents. But I'll leave that to whoever really needs it. It shouldn't be a problem if there are are a relatively small set of child nodes in any given parent.
    Also, note that the root node in the model cannot be made invisible, cuz it'd be redundant since JTree can be set to hide the root node.
    // *** HideableTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    * <code>HideableTreeModel</code> is an <code>TreeNodeTreeModel</code>
    * implementation for <code>HideableMutableTreeNode</code> objects.  The
    * model can also take any other <code>javax.swing.tree.TreeNode</code>
    * objects. 
    public class HideableTreeModel extends TreeNodeTreeModel {
          * Creates a new <code>HideableTreeModel</code> object.
          * @param  root  the root node
         public HideableTreeModel(TreeNode root) {
              super(root);
          * Checks if the specified node is visible.  A node can only be
          * hidden if the node is an instance of <code>HideableMutableTreeNode</code>.  <br />
          * <br />
          * Note that this only test the visibility of the specified node, not
          * whether a parent node is visible.  Use <code>isPathToNodeVisible(Object)</code>
          * to check if the full path is visible. 
          * @param  node  the node
          * @param  true if the node is visible, else false
         public boolean isNodeVisible(Object node) {
              if(node != getRoot()) {
                   if(node instanceof HideableMutableTreeNode) {
                        return ((HideableMutableTreeNode)node).isVisible();
              return true;
          * Sets the specified node to be hidden.  A node can only be made hidden
          * if the node is an instance of <code>HideableMutableTreeNode</code>.  <br />
          * <br />
          * Note that this method will notify the tree to reflect any changes to
          * node visibility.  <br />
          * <br />
          * Note that this will not alter the visibility of any nodes in the
          * specified node's path to the root node.  Use
          * <code>ensurePathToNodeVisible(Object)</code> instead to make sure the
          * full path down to that node is visible.  <br />
          * <br />
          * Note that this method will notify the tree to reflect any changes to
          * node visibility. 
          * @param  node  the node
          * @param  v     true for visible, false for hidden
          * @param  true if the node's visibility could actually change, else false
         public boolean setNodeVisible(Object node, boolean v) {
              // can't hide root
              if(node != getRoot()) {
                   if(node instanceof HideableMutableTreeNode) {
                        HideableMutableTreeNode n = (HideableMutableTreeNode)node;
                        // don't fix what ain't broke...
                        if(v != n.isVisible()) {
                             TreeNode parent = n.getParent();
                             if(v) {
                                  // need to get index after showing...
                                  n.setVisible(v);
                                  int index = getIndexOfChild(parent, n);
                                  super.nodeInserted(parent, n, index);
                             } else {
                                  // need to get index before hiding...
                                  int index = getIndexOfChild(parent, n);
                                  n.setVisible(v);
                                  super.nodeRemoved(parent, n, index);
                        return true;
              return false;
          * Checks if the specified node is visible and all nodes above it are
          * visible. 
          * @param  node  the node
          * @param  true if the path is visible, else false
         public boolean isPathToNodeVisible(Object node) {
              Object[] path = getPathToRoot(node);
              for(int i = 0; i < path.length; i++) {
                   if(!isNodeVisible(path)) {
                        return false;
              return true;
         * Sets the specified node and all nodes above it to be visible.
         * Note that this method will notify the tree to reflect any changes to
         * node visibility.
         * @param node the node
         public void ensurePathToNodeVisible(Object node) {
              Object[] path = getPathToRoot(node);
              for(int i = 0; i < path.length; i++) {
                   setNodeVisible(path[i], true);
         * Returns the child of parent at index index in the parent's child array.
         * @param parent the parent node
         * @param index the index
         * @return the child or null if no children
         public Object getChild(Object parent, int index) {
              if(parent instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   for(int i = 0, j = -1; i < p.getChildCount(); i++) {
                        TreeNode pc = (TreeNode)p.getChildAt(i);
                        if(isNodeVisible(pc)) {
                             j++;
                        if(j == index) {
                             return pc;
              return null;
         * Returns the number of children of parent.
         * @param parent the parent node
         * @return the child count
         public int getChildCount(Object parent) {
              int count = 0;
              if(parent instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   for(int i = 0; i < p.getChildCount(); i++) {
                        TreeNode pc = (TreeNode)p.getChildAt(i);
                        if(isNodeVisible(pc)) {
                             count++;
              return count;
         * Returns the index of child in parent.
         * @param parent the parent node
         * @param child the child node
         * @return the index of the child node in the parent
         public int getIndexOfChild(Object parent, Object child) {
              int index = -1;
              if(parent instanceof TreeNode && child instanceof TreeNode) {
                   TreeNode p = (TreeNode)parent;
                   TreeNode c = (TreeNode)child;
                   if(isNodeVisible(c)) {
                        index = 0;
                        for(int i = 0; i < p.getChildCount(); i++) {
                             TreeNode pc = (TreeNode)p.getChildAt(i);
                             if(pc.equals(c)) {
                                  return index;
                             if(isNodeVisible(pc)) {
                                  index++;
              return index;
         * Main method for testing.
         * @param args the command-line arguments
         public static void main(String[] args) {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              HideableMutableTreeNode root = new HideableMutableTreeNode("root");
              root.add(new HideableMutableTreeNode("child_1"));
              final HideableMutableTreeNode c2 = new HideableMutableTreeNode("child_2");
              c2.setVisible(false);
              final HideableMutableTreeNode c2a = new HideableMutableTreeNode("child_2_A");
              c2.add(c2a);
              c2.add(new HideableMutableTreeNode("child_2_B"));
              root.add(c2);
              HideableMutableTreeNode c3 = new HideableMutableTreeNode("child_3");
              HideableMutableTreeNode cC = new HideableMutableTreeNode("child_3_C");
              cC.setVisible(false);
              c3.add(cC);
              c3.add(new HideableMutableTreeNode("child_3_D"));
              root.add(c3);
              root.add(new HideableMutableTreeNode("child_4"));
              root.add(new HideableMutableTreeNode("child_5"));
              DefaultMutableTreeNode c6 = new DefaultMutableTreeNode("child_6");
              c6.add(new DefaultMutableTreeNode("child_6_A"));
              c6.add(new DefaultMutableTreeNode("child_6_B"));
              root.add(c6);
              final HideableTreeModel model = new HideableTreeModel(root);
              JTree tree = new JTree(model);
              f.getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
              JButton b = new JButton("toggle");
              b.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        model.setNodeVisible(c2, !model.isNodeVisible(c2));
                        //model.ensurePathToNodeVisible(c2a);
              f.getContentPane().add(b, BorderLayout.SOUTH);
              f.pack();
              f.setSize(300, 500);
              f.show();
    // *** HideableMutableTreeNode ***
    import javax.swing.*;
    import javax.swing.tree.*;
    * <code>HideableMutableTreeNode</code> is a <code>DefaultMutableTreeNode</code>
    * implementation that works with <code>HideableTreeModel</code>.
    public class HideableMutableTreeNode extends DefaultMutableTreeNode {
         * The node is visible flag.
         public boolean visible = true;
         * Creates a tree node that has no parent and no children, but which
         * allows children.
         public HideableMutableTreeNode() {
              super();
         * Creates a tree node with no parent, no children, but which allows
         * children, and initializes it with the specified user object.
         * @param userObject - an Object provided by the user that
         * constitutes the node's data
         public HideableMutableTreeNode(Object userObject) {
              super(userObject);
         * Creates a tree node with no parent, no children, initialized with the
         * specified user object, and that allows children only if specified.
         * @param userObject - an Object provided by the user that
         * constitutes the node's data
         * @param allowsChildren - if true, the node is allowed to have child
         * nodes -- otherwise, it is always a leaf node
         public HideableMutableTreeNode(Object userObject, boolean allowsChildren) {
              super(userObject, allowsChildren);
         * Checks if the node is visible.
         * @return true if the node is visible, else false
         public boolean isVisible() {
              return this.visible;
         * Sets if the node is visible.
         * @param v true if the node is visible, else false
         public void setVisible(boolean v) {
              this.visible = v;
    // *** TreeNodeTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    * <code>TreeNodeTreeModel</code> is an <code>AbstractTreeModel</code>
    * implementation for <code>javax.swing.tree.TreeNode</code> objects.
    public class TreeNodeTreeModel extends AbstractTreeModel {
         * Creates a new <code>TreeNodeTreeModel</code> object.
         * @param root the root node
         public TreeNodeTreeModel(TreeNode root) {
              super();
              setRoot(root);
         * Returns the parent of the child node.
         * @param node the child node
         * @return the parent or null if root
         public Object getParent(Object node) {
              if(node != getRoot() && (node instanceof TreeNode)) {
                   return ((TreeNode)node).getParent();
              return null;
         * Returns the child of parent at index index in the parent's child array.
         * @param parent the parent node
         * @param index the index
         * @return the child or null if no children
         public Object getChild(Object parent, int index) {
              if(parent instanceof TreeNode) {
                   return ((TreeNode)parent).getChildAt(index);
              return null;
         * Returns the number of children of parent.
         * @param parent the parent node
         * @return the child count
         public int getChildCount(Object parent) {
              if(parent instanceof TreeNode) {
                   return ((TreeNode)parent).getChildCount();
              return 0;
         * Returns the index of child in parent.
         * @param parent the parent node
         * @param child the child node
         * @return the index of the child node in the parent
         public int getIndexOfChild(Object parent, Object child) {
              if(parent instanceof TreeNode && child instanceof TreeNode) {
                   return ((TreeNode)parent).getIndex((TreeNode)child);
              return -1;
         * Returns true if node is a leaf.
         * @param node the node
         * @return true if the node is a leaf
         public boolean isLeaf(Object node) {
              if(node instanceof TreeNode) {
                   return ((TreeNode)node).isLeaf();
              return true;
         * Main method for testing.
         * @param args the command-line arguments
         public static void main(String[] args) {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
              root.add(new DefaultMutableTreeNode("child_1"));
              DefaultMutableTreeNode c2 = new DefaultMutableTreeNode("child_2");
              c2.add(new DefaultMutableTreeNode("child_2_A"));
              c2.add(new DefaultMutableTreeNode("child_2_B"));
              root.add(c2);
              root.add(new DefaultMutableTreeNode("child_3"));
              root.add(new DefaultMutableTreeNode("child_4"));
              JTree tree = new JTree(new TreeNodeTreeModel(root));
              f.getContentPane().add(new JScrollPane(tree));
              f.pack();
              f.setSize(300, 500);
              f.show();
    // *** AbstractTreeModel ***
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    public abstract class AbstractTreeModel implements TreeModel {
         * The list of tree model listeners.
         private Vector modelListeners = new Vector();
         * The root object of the tree.
         private Object root = null;
         * Basic no-op constructor.
         public AbstractTreeModel() {
         * Gets the root object of the tree.
         * @return the root object
         public Object getRoot() {
              return this.root;
         * Sets the root object of the tree.
         * @param r the root object
         protected void setRoot(Object r) {
              this.root = r;
         * Gets the path to the root node for the specified object.
         * @param node the root node
         * @return the path to the object or <CODE>null</CODE>
         public Object[] getPathToRoot(Object node) {
              return getPathToRoot(node, 0);
         * Gets the path to the root node for the specified object.
         * @param node the root node
         * @param i the current index
         * @return the path to the object or <CODE>null</CODE>
         private Object[] getPathToRoot(Object node, int i) {
              Object anode[];
              if(node == null) {
                   if(i == 0) {
                        return null;
                   anode = new Object[i];
              } else {
                   i++;
                   if(node == getRoot()) {
                        anode = new Object[i];
                   } else {
                        anode = getPathToRoot(getParent(node), i);
                   anode[anode.length - i] = node;
              return anode;
         * Gets the parent object of the specified object. This method is not
         * part of the <code>javax.swing.tree.TreeModel</code> interface, but is
         * required to support the <code>getPathToRoot(Object)</code> method,
         * which is widely used in this class. Therefore, it is important to
         * correctly implement this method.
         * @param obj the object
         * @parma the parent object or null if no parent or invalid object
         protected abstract Object getParent(Object obj);
         * Adds a listener for the <CODE>TreeModelEvent</CODE> posted after the
         * tree changes.
         * @param l the tree model listener
         public void addTreeModelListener(TreeModelListener l) {
              modelListeners.addElement(l);
         * Removes a listener previously added with addTreeModelListener().
         * @param l the tree model listener
         public void removeTreeModelListener(TreeModelListener l) {
              modelListeners.removeElement(l);
         * Forces the tree to reload. This is useful when many changes occur
         * under the root node in the tree structure.
         * <b>NOTE:</b> This will cause the tree to be collapsed. To maintain
         * the expanded nodes, see the <code>getExpandedPaths(JTree)</code>
         * and <code>expandPaths(JTree, ArrayList)</code> methods.
         * @see #getExpandedPaths(JTree)
         * @see #expandPaths(JTree, ArrayList)
         public void reload() {
              reload(getRoot());
         * Forces the tree to repaint. This is useful when many changes occur
         * under a specific node in the tree structure.
         * <b>NOTE:</b> This will cause the tree to be collapsed below the
         * updated node.
         * @param node the node that changed
         public void reload(Object node) {
              if(node != null) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   fireTreeStructureChanged(new TreeModelEvent(this, tp));
         * Messaged when the user has altered the value for the item identified
         * by <CODE>path</CODE> to <CODE>newValue</CODE>.
         * @param path the path to the changed object
         * @param newValue the new value
         public void valueForPathChanged(TreePath path, Object newValue) {
              nodeChanged(path.getLastPathComponent());
         * Notifies the tree that nodes were inserted. The index is looked up
         * automatically.
         * @param node the parent node
         * @param child the inserted child node
         public void nodeInserted(Object node, Object child) {
              nodeInserted(node, child, -1);
         * Notifies the tree that nodes were inserted.
         * @param node the parent node
         * @param child the inserted child node
         * @param index the index of the child
         public void nodeInserted(Object node, Object child, int index) {
              if(index < 0) {
                   index = getIndexOfChild(node, child);
              if(node != null && child != null && index >= 0) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   int[] ai = { index };
                   Object[] ac = { child };
                   fireTreeNodesInserted(new TreeModelEvent(this, tp, ai, ac));
         * Notifies the tree that nodes were removed. The index is required
         * since by this point, the object will no longer be in the tree.
         * @param node the parent node
         * @param child the removed child node
         * @param index the index of the child
         public void nodeRemoved(Object node, Object child, int index) {
              if(node != null && child != null && index >= 0) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   int[] ai = { index };
                   Object[] ac = { child };
                   fireTreeNodesRemoved(new TreeModelEvent(this, tp, ai, ac));
         * Notifies the tree that a node was changed.
         * @param node the changed node
         public void nodeChanged(Object node) {
              if(node != null) {
                   TreePath tp = new TreePath(getPathToRoot(node));
                   fireTreeNodesChanged(new TreeModelEvent(this, tp, null, null));
         * Fires "tree nodes changed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesChanged(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesChanged(event);
         * Fires "tree nodes inserted" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesInserted(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesInserted(event);
         * Fires "tree nodes removed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeNodesRemoved(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeNodesRemoved(event);
         * Fires "tree structure changed" events to all listeners.
         * @param event the tree model event
         protected void fireTreeStructureChanged(TreeModelEvent event) {
              for(int i = 0; i < modelListeners.size(); i++) {
                   ((TreeModelListener)modelListeners.elementAt(i)).treeStructureChanged(event);
         * Records the list of currently expanded paths in the specified tree.
         * This method is meant to be called before calling the
         * <code>reload()</code> methods to allow the tree to store the paths.
         * @param tree the tree
         * @param pathlist the list of expanded paths
         public ArrayList getExpandedPaths(JTree tree) {
              ArrayList expandedPaths = new ArrayList();
              addExpandedPaths(tree, tree.getPathForRow(0), expandedPaths);
              return expandedPaths;
         * Adds the expanded descendants of the specifed path in the specified
         * tree to the internal expanded list.
         * @param tree the tree
         * @param path the path
         * @param pathlist the list of expanded paths
         private void addExpandedPaths(JTree tree, TreePath path, ArrayList pathlist) {
              Enumeration enum = tree.getExpandedDescendants(path);
              while(enum.hasMoreElements()) {
                   TreePath tp = (TreePath)enum.nextElement();
                   pathlist.add(tp);
                   addExpandedPaths(tree, tp, pathlist);
         * Re-expands the expanded paths in the specified tree. This method is
         * meant to be called before calling the <code>reload()</code> methods
         * to allow the tree to store the paths.
         * @param tree the tree
         * @param pathlist the list of expanded paths
         public void expandPaths(JTree tree, ArrayList pathlist) {
              for(int i = 0; i < pathlist.size(); i++) {
                   tree.expandPath((TreePath)pathlist.get(i));

    Hey
    I'm not trying to show anyone up here, but having just built a tree model for displaying an XML document in a tree, I thought this seemed like a neat exercise.
    I implemented this very differently from the @OP. I only have one class, HiddenNodeTreeModel. All the hidden node data is stored in the model itself in my class. The advantage of what I've created is it will work with any TreeModel. The disadvantage is that I think it's not going to be very scalable - the additional computing to get the number of child nodes and to adjust indexes is heavy. So if you need a scalable solution definitely don't use this.
    Anyway here you go
    HiddenNodeTreeModel.java
    ======================
    package tjacobs.ui.tree;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Iterator;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JTree;
    import javax.swing.event.TreeModelListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import tjacobs.ui.WindowUtilities;
    public class HiddenNodeTreeModel implements TreeModel {
         TreeModel mModel;
         ArrayList<Object> mHidden = new ArrayList<Object>();
         public HiddenNodeTreeModel (TreeModel model) {
              mModel = model;
         public void addTreeModelListener(TreeModelListener arg0) {
              mModel.addTreeModelListener(arg0);
         private ArrayList<Integer> getHiddenChildren(Object parent) {
              ArrayList<Integer> spots = new ArrayList<Integer>();
              Iterator _i = mHidden.iterator();
              while (_i.hasNext()) {
                   Object hidden = _i.next();
                   int idx = mModel.getIndexOfChild(parent, hidden);
                   if (idx != -1) {
                        spots.add(idx);
              return spots;
         public Object getChild(Object arg0, int index) {
              ArrayList<Integer> spots = getHiddenChildren(arg0);
              Collections.sort(spots);
              Iterator<Integer> _i = spots.iterator();
              while (_i.hasNext()) {
                   int num = _i.next();
                   if (num <= index) {
                        index++;
              return mModel.getChild(arg0, index);
         public int getChildCount(Object arg0) {
              ArrayList list = getHiddenChildren(arg0);
              System.out.println("size = " + list.size());
              return mModel.getChildCount(arg0) - list.size();
         public int getIndexOfChild(Object arg0, Object arg1) {
              int index = mModel.getIndexOfChild(arg0, arg1);
              ArrayList<Integer> spots = getHiddenChildren(arg0);
              Collections.sort(spots);
              Iterator<Integer> _i = spots.iterator();
              int toSub = 0;
              while (_i.hasNext()) {
                   int num = _i.next();
                   if (num <= index) {
                        toSub++;
              return index - toSub;
         public Object getRoot() {
              // TODO Auto-generated method stub
              return mModel.getRoot();
         public boolean isLeaf(Object arg0) {
              // TODO Auto-generated method stub
              return mModel.isLeaf(arg0);
         public void removeTreeModelListener(TreeModelListener arg0) {
              mModel.removeTreeModelListener(arg0);
         public void valueForPathChanged(TreePath arg0, Object arg1) {
              mModel.valueForPathChanged(arg0, arg1);
         public void hideNode(Object node) {
              if (node instanceof TreePath) {
                   node = ((TreePath)node).getLastPathComponent();
              mHidden.add(node);
         public void showNode(Object node) {
              mHidden.remove(node);
         public void showAll() {
              mHidden.clear();
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              DefaultMutableTreeNode A = new DefaultMutableTreeNode("A");
              DefaultMutableTreeNode B = new DefaultMutableTreeNode("B");
              DefaultMutableTreeNode C = new DefaultMutableTreeNode("C");
              DefaultMutableTreeNode D = new DefaultMutableTreeNode("D");
              DefaultMutableTreeNode E = new DefaultMutableTreeNode("E");
              DefaultMutableTreeNode F = new DefaultMutableTreeNode("F");
              A.add(B);
              B.add(C);
              B.add(D);
              B.add(E);
              E.add(F);
              DefaultTreeModel model = new DefaultTreeModel(A);
              final HiddenNodeTreeModel hmodel = new HiddenNodeTreeModel(model);
              final JTree tree = new JTree(hmodel);
              JFrame jf = new JFrame("HiddenNodeTreeModel Test");
              jf.add(tree);
              JMenuBar bar = new JMenuBar();
              jf.setJMenuBar(bar);
              JMenu menu = new JMenu("Options");
              bar.add(menu);
              final JMenuItem hide = new JMenuItem("Hide");
              final JMenuItem show = new JMenuItem("ShowAll");
              menu.add(hide);
              menu.add(show);
              ActionListener al = new ActionListener() {
                   public void actionPerformed(ActionEvent ae) {
                        if (ae.getSource() == hide) {
                             hmodel.hideNode(tree.getSelectionPath());
                             tree.updateUI();
                        else {
                             hmodel.showAll();
                             tree.updateUI();
              hide.addActionListener(al);
              show.addActionListener(al);
              jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              jf.setBounds(100,100,100,100);
              jf.setVisible(true);
    }

  • How to resize a custom tree node like you would a JFrame window?

    Hello,
    I am trying to resize a custom tree node like you would a JFrame window.
    As with a JFrame, when your mouse crosses the Border, the cursor should change and you are able to drag the edge to resize the node.
    However, I am faced with a problem. Border cannot detect this and I dont want to use a mouse motion listener (with a large number of nodes, I fear it will be inefficient, calculating every node's position constantly).
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Insets;
    import java.util.EventObject;
    import javax.swing.BorderFactory;
    import javax.swing.Box;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellEditor;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeSelectionModel;
    public class ResizeNode extends JPanel {
           AnilTreeCellRenderer2 atcr;
           AnilTreeCellEditor2 atce;
           DefaultTreeModel treeModel;
           JTree tree;
           DefaultMutableTreeNode markedNode = null;
         public ResizeNode() {
                super(new BorderLayout());
                   treeModel = new DefaultTreeModel(null);
                   tree = new JTree(treeModel);          
                  tree.setEditable(true);
                   tree.getSelectionModel().setSelectionMode(
                             TreeSelectionModel.SINGLE_TREE_SELECTION);
                   tree.setShowsRootHandles(true);
                  tree.setCellRenderer(atcr = new AnilTreeCellRenderer2());
                  tree.setCellEditor(atce = new AnilTreeCellEditor2(tree, atcr));
                   JScrollPane scrollPane = new JScrollPane(tree);
                   add(scrollPane,BorderLayout.CENTER);
         public void setRootNode(DefaultMutableTreeNode node) {
              treeModel.setRoot(node);
              treeModel.reload();
           public static void main(String[] args){
                ResizeNode tb = new ResizeNode();
                tb.setPreferredSize(new Dimension(400,200));
                  JFrame frame = new JFrame("ResizeNode");
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setContentPane(tb);
                  frame.setSize(400, 200);
                  frame.pack();
                  frame.setVisible(true);
                  tb.populate();
         private void populate() {
              TextAreaNode2 r = new TextAreaNode2(this);
               setRootNode(r);
               TextAreaNode2 a = new TextAreaNode2(this);
               treeModel.insertNodeInto(a, r, r.getChildCount());          
    class AnilTreeCellRenderer2 extends DefaultTreeCellRenderer{
    TreeBasic panel;
    DefaultMutableTreeNode currentNode;
      public AnilTreeCellRenderer2() {
         super();
    public Component getTreeCellRendererComponent
       (JTree tree, Object value, boolean selected, boolean expanded,
       boolean leaf, int row, boolean hasFocus){
         TextAreaNode2 currentNode = (TextAreaNode2)value;
         NodeGUI2 gNode = (NodeGUI2) currentNode.gNode;
        return gNode.box;
    class AnilTreeCellEditor2 extends DefaultTreeCellEditor{
      DefaultTreeCellRenderer rend;
      public AnilTreeCellEditor2(JTree tree, DefaultTreeCellRenderer r){
        super(tree, r);
        rend = r;
      public Component getTreeCellEditorComponent(JTree tree, Object value,
       boolean isSelected, boolean expanded, boolean leaf, int row){
        return rend.getTreeCellRendererComponent(tree, value, isSelected, expanded,
         leaf, row, true);
      public boolean isCellEditable(EventObject event){
        return true;
    class NodeGUI2 {
         final ResizeNode view;
         Box box = Box.createVerticalBox();
         final JTextArea aa = new JTextArea( 1, 5 );
         final JTextArea aaa = new JTextArea( 1, 8 );
         NodeGUI2( ResizeNode view_ ) {
              this.view = view_;
              box.add( aa );
              aa.setBorder( BorderFactory.createMatteBorder( 0, 0, 1, 0, Color.GREEN ) );
              box.add( aaa );
              box.setBorder( BorderFactory.createMatteBorder( 5, 5, 5, 5, Color.CYAN ) );
         private Dimension getEditorPreferredSize() {
              Insets insets = box.getInsets();
              Dimension boxSize = box.getPreferredSize();
              Dimension aaSize = aa.getPreferredSize();
              Dimension aaaSize = aaa.getPreferredSize();
              int height = aaSize.height + aaaSize.height + insets.top + insets.bottom;
              int width = Math.max( aaSize.width, aaaSize.width );
              if ( width < boxSize.width )
                   width += insets.right + insets.left + 3;     // 3 for cursor
              return new Dimension( width, height );               
    class TextAreaNode2 extends DefaultMutableTreeNode {  
         NodeGUI2 gNode;
         TextAreaNode2(ResizeNode view_) {     
              gNode = new NodeGUI2(view_);
    }

    the node on the tree is only painted on using the
    renderer to do the painting work. A mouse listener
    has to be added to the tree, and when moved over an
    area, you have to determine if you are over the
    border and which direction to update the cursor and
    to know which way to resize when dragged. One of the
    BasicRootPaneUI has some code that can help determine
    that.Thanks for replying. What is your opinion on this alternative idea that I just had?
    I am wondering if it might be easier to have a toggle button in the node that you click when you want to resize the node. Then a mouse-down and dragging the mouse will resize the node. Mouse-up will reset the toggle button, and so will mouse down in an invalid area.
    Anil

Maybe you are looking for

  • What are we supposed to do when the magic mouse stops working?

    Everything was fine last night, until my mouse again lost it's connection. The light was blinking fine, but no connection, I changed batteries (even tho the ones inside showed nearly a full charge), still wouldn't work. I realized, ok, now what? Shou

  • Receipt Received From Apple

    How do you stop Apple from sending you a receipt from the iTunes Store to your house mailbox? Please help....

  • Database operation with web dynpro java

    Hi, Our portal installed on MaxDB database.We need to develop web dynpro java application has some database opeartions (insert,update, delete, select) on MaxDB database. 1- Is there a blog or sample how can it be done over MaxDB? 2- Is there explorin

  • 8.1.3 Caused Safari Search Bar Issue

    I Upgraded to 8.1.3 this morning and now the Safari search bar has moved to the very top of my screen, merged with the battery and use information. This is making it very difficult to use Safari as it is almost impossible to click on the search bar t

  • Blackberry Travel v3.2.1.3 Issue

    I have recently started using this app. Issues of Note. - When it automatically scans my emails for a trip, the app lists my flight and hotel bookings twice. ie it will say I have 2 flights with the exact same detail for the single flight I have book