Java doc
- https://help.eclipse.org/latest/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/layout/package-summary.html
SWT 布局类型
- 绝对布局 absolute
- 表单布局 FormLayout (相对布局)
- 填充布局 FillLayout(水平填充、垂直填充)
- 网格布局 GridLayout(列数、列宽度是否相同)
- 行布局 RowLayout(水平行、垂直行)
- 栈布局 StackLayout (后进先显示)
通过Composite.setLayout()方法设置布局
org.eclipse.swt.widgets.Composite#setLayout(null)
绝对布局 absolute
设置绝对布局
setLayout(null)
设置组件位置、大小
通过Control.setBounds
方法设置组件位置、大小
org.eclipse.swt.widgets.Control#setBounds (int x, int y, int width, int height)
x:水平距离
y:垂直距离
(0,0)是窗体的左上角。
案例:
btnNewButton.setBounds(0, 0, 50, 50);//按钮显示在窗体的左上角宽、度高多都为50<