question

hemant avatar image
hemant asked hemant posted

How to set the size of UI controls

Hi,

 

We are trying to set the size of UI controls like table,group etc. but its not getting reflected.

We have already tried setBounds and setSize method but it didn't work.I have attached the sreen shot of our UI.

 

Any feedback will be helpful.

 

Thanks,

Hemant

iTestsdk
UiScreenshot.JPG (86.4 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AdamB avatar image
AdamB answered AdamB posted

What layout manager are you using?  I'd recommend using the GridLayout.  It is flexable and fairly easy to figurout initially.  As Paul mentioned, you set the layout on the containing Composite and then setLayoutData on all the childern.  The grid layout works by specifying the number of "columns" and then you can place your controls in those columns.  Controls can "span" columns and rows to get the size right.  It will also manage resizing controls once you have it set right.

 

If you want to draw out or explain how you'd like it to work we could help with more specifics.  For instance a screen shot from a power point, or a camera pic of a hand drawing would work too.

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

PaulD avatar image
PaulD answered PaulD posted

You are constructing your UI using SWT and JFace -- standard Eclipse technologies.  Admittedly, these can be a little obscure, especially when you're first learning them.  There are several good books available and you'll find lots of resources on the Internet to help you if you search for SWT and JFace.

 

Meanwhile, your immediate problem is that SWT uses the concept of a layout manager when laying out controls.  When you add a control, you will typically have to call setLayoutData() on that control to tell it how to position itself relative to its container, and SWT then takes care of finding the appropriate overall sizes and positions, etc.  From the look of your screenshot, you've already made good progress.  You probably just need to add a few calls to setLayout and setLayoutData.  If you want to post a little of your code, we could probably point out what is missing.

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.