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

>Are you saying that I'll need special code for each PLAF that I'll support?
>--Erik Ostermueller

<caveat>
My experience with PLAFs is limited to Windows and Metal.
I have zero experience with Mac or Motif.
</caveat>

To your question: it depends on the component in question and how much you want _your_ component to match the current LAF.

Most components have much of the behavior factored into the plaf.basic.Basic<component>UI superclass with LAF specific behavior in subclasses.  At one extreme you have JTable where the subclasses have zero added behavior.  At the other you have JFileChooser

where the impl is incredibly platform specific -- both Metal and Windows FileChooserUI's are about 2KLOC each.

In your case (JTree) the LAF extensions are pretty small - about 200 LOC.

The other thing to consider is whether your program allows users to plug in their own LAF: like jGoodies or Kunstaff.
Do you want your component to match those exactly as well? 
Pragmatically, you're probably better off deciding how you want it to display and doing it once.  JMO

It's possible you could go a long way toward solving your problem by overriding getPathForRow and getRowForPath.  I.e.
implementing a custom LayoutCache.

P.S.  You would really be surprised at how far you can stretch the existing JTreeUI. 
I just recently did one that supported expanding across multiple dimensions. 
You would right-click to choose among the different (non-default) expansion directions. 
The expansion controls were the node's icon which changed to indicate the current direction choosen.


~rmp

-----Original Message-----
From: Erik Ostermueller [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 29, 2003 1:58 PM
To: [EMAIL PROTECTED]
Cc: Prescott, Ralph
Subject: RE: customizing the layout of nodes in a JTree


Thanks.  That sounds like a concrete start -- it will
all take me a bit to digest, though.  For starters,
help me understand this part:

--- "Prescott, Ralph" <[EMAIL PROTECTED]>
wrote:  >> You have to support multiple PLAFs and
 >> so have to implement multiple new extensions :(


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

Reply via email to