tags:

views:

18

answers:

2

Is it possible to have an SWT tree with lines of different height ?

Manuel

A: 

Well, you could of course call setFont() on the TreeItem in question, and give it a larger font than that used by the other TreeItem rows. However, this may not be what you want... having multiple font sizes in the Tree.

A second more hack-y alternative might be to instead use the setImage() method on TreeItem... setting a white (or whatever) background image for each row, with the taller rows using a bigger image than the shorter rows.

This second approach would give you custom row heights without changing the fonts, although you would want to be sure to choose a background image of the same color as the system default background color. Perhaps you could even create your Image objects programmatically in-memory to ensure this.

Steve Perkins
The image hack is a nice idea. Does it work? I recall trying to achieve something similar some time ago and never found a solution that works across all platforms. This is the kind of hacks that might not work well on all SWT implementations, so make sure you carefully test it.
zvikico
Does this solution really gives different height for each row ? Today I tried an other solution with a Measure Listener: it works but sets all the rows to the tallest height. Why this is different when using images of different sizes ?
Manuel Selva
+1  A: 

In a SWT tree or table the items cannot different heights. If you need to make every row with different height, you must use a custom widget, like KTable or nebula grid for example.

True Soft