SWT: How to get the default (preferred) size of a Control
An SWT component only has a getSize()
method. It returns the actual size of this control. But how to get the default size of a component, especially if a different one already has been 开发者_如何学Goset before?
You can obtain the default size by calling computeSize(SWT.DEFAULT, SWT.DEFAULT)
on your widget. You may pass a default height or width instead of SWT.DEFAULT
in cases such as a multiline Label, where you'd want to know its natural height given a maximum line width, for instance.
For all standard widgets, computeSize
disregard the value passed in any previous setSize
calls.
精彩评论