[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] [Home]

Re: jCVS version using Swing UI available






time@ice.com wrote:

> > > The other complaint I have heard about JTree is
> > > that is is not very "pixel efficient", but I believe
> > > this can be fixed with a customer renderer.
> >
> > Yes, I think you mean that it always paints the background for
> > every cell. The version I made does that too; for the renderer,
> > it uses a JPanel with three JLabel's, one for the name and the
> > icon in front of it, one for the version and one for the
> > timestamp. But I don't see how that could be changed a lot.
>
> In ICEMail, I had a problem with the rendering when I was trying
> to mix a JLabel with my own drawing. That was bad. I think, however,
> that if I went with my own JComponent I could get it to work right,
> but then I am reproducing JLabel, which sucks.

I haven't used it, but perhaps OverlayLayout would help here?

> How did you manage to get the columns of labels to line up properly?
> In other words, how did you get the timestamps to line up vertically,
> or did you just punt on that?

I first tried to do it in the CellRenderer, but the layout manager would
mock it up. I suppose you could set the layout manager of a JPanel to
null and do it in the JPanel, but I went for writing a simple
LayoutManager instead.

What it does is:

- I added a parent field to CVSListItem
- the layoutmanager looks up the sublist of the parent
- in CVSListItemVector I some methods that, given a FontMetrics object,
looks up the maximum length of the name, version and timestamp of all
it's children. It uses caching so it doesn't get recalculated all the
time.

That way the indenting of the labels is local to each "directory" only,
but that looks good. It doesn't add too much whitespace.

Erwin