有没有办法改变在行布局中创建的元素的顺序,我想在首先显示的元素中显示它.例如,如果我创建element1,那么element2 element3,element4
我想将布局视为element4 element3 element2 element1
这意味着最后创建的元素将是将在shell中显示的第一个元素.
有没有简单的方法来处理行布局并执行它.
我想更改以下示例以显示Button99 Button98 Button97 Button96 Button95 Button94 ....................................
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class TestExample
{
public static void main(String[] args)
{
Display display = Display.getDefault();
Shell shell = new Shell(display);
RowLayout rowLayout = new RowLayout();
shell.setLayout(rowLayout);
for (int i=0;i<100;i++)
{
Button b1 = new Button(shell, SWT.PUSH);
b1.setText("Button"+i);
}
shell.open();
while (!display.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.
似乎没有可以设置的属性,以便 RowLayout 的元素将以相反的顺序放置。因此,您可以反转数组中的元素,然后将它们全部添加到循环中,或者对于这个特定示例,只需更改 for 循环的开始和结束条件,使其类似于 Button99 Button98 ... :D
| 归档时间: |
|
| 查看次数: |
1433 次 |
| 最近记录: |