Title: RE: customizing the layout of nodes in a JTree

This is a view issue not model issue.
To do this you're probably going to have to provide your own UIDelegate.
Take a look at javax.swing.plaf.basic.BasicTreeUI to see how this is done now.
It's 3800 lines of code but much of it is the controller aspect not the drawing aspect.

I'm not making any claims that this will be easy.  Extending delegates invariably hits one of several problems:
    * You have to support multiple PLAFs and so have to implement multiple new extensions :(
    * You want a simple extension but the method you want to override is private or package :(
    * You have to cut/paste code making you vulnerable to changes in the next JDK release :(
    * What you think is view behavior is implemented by the component or model and you're stuck with it :(
              JTable.getCellRect is a good example of this
    * What you think is model behavior is implemented by the view and you're stuck with it :(
               
HTH
~rmp

-----Original Message-----
From: Erik Ostermueller [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 27, 2003 11:46 AM
To: [EMAIL PROTECTED]
Subject: customizing the layout of nodes in a JTree


Hello all,
I could use some design suggestions.
I'd like to write a swing app that uses a tree.
Most trees are rendered like this, with every
single child showing up below the parent:

Parent
 |-Child
 |-Child
 |-Child
     |-Grandchild
     |-Grandchild

I'd like to render my nodes differently, like this:

        |--child
        |
Parent -+--child
        |
        |
        |         |-grandchild
        |--child -+
                  |-grandchild

Reply via email to