单击此处,在此示例中,文本显示在右侧,我希望它位于图像下方。
如何使用SWT本身执行此操作?
要显示下面带有文字的图像,您需要两个标签和一个布局以将它们相互定位
Composite parent = new ...
RowLayout layout = new RowLayout( SWT.VERTICAL );
layout.center = true;
parent.setLayout( layout );
Label imageLabel = new Label( parent, SWT.NONE );
imageLabel.setImage( ... );
Label textLabel = new Label( parent, SWT.NONE );
textLabel.setText( "text" );
为了使标签左对齐,请省略layout.center = true
。默认情况下,的RowLayout
间距为3个像素,可以通过该spacing
字段进行更改。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句