Domanda

I have been trying for some time to create a dialog which contains a composite. The composite has the ability to add horizontal and vertical scrollbars if it becomes too small to show its content. Inside the composite there is a tree widget. This tree widget should provide in a similar fashion scrollbars if the columns or the rows cannot be displayed in the given area.

An excellent example of what I am trying to do is the Validation option in the Window > Preferences dialog of Eclipse. It has a table which provides scrollbars if a column is resized to be bigger. In the same time if the size of the dialog is decreased it provides a scrollbar for the composite.

What I have tried to do is create a ScrolledComposite put another Composite inside which has GridLayout. After that I put a Tree and a bunch of labels and buttons inside the composite. However when put too much TreeColumns or TreeItems inside the Tree simply expands in size instead of displaying scrollbars.

Any idea what I am doing wrong and how it should be done properly? Thank you in advance.

È stato utile?

Soluzione

Try setting a width hint on the Tree using something like below:

Tree tree = ...
GridData gd = new GridData();
gd.widthHint = XX;
gd.heightHint = XX;
tree.setLayoutData(gd);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top