我有一个树状视图,并且有一个名为“详细信息”的组,该组在树状视图中显示所选项目的详细信息(选中时)。

使用SWT组时,无法在组边界内设置字符串。
我只能使用设置组标题的“ group.setText()”方法设置标题。

    --Details-----------------
   |                          |
   |  item 1 is selected      |
   |                          |
    --------------------------


我要显示上图所示的选择。

最佳答案

Group只是一个带标题的Composite,如果您想在其中添加内容,则必须添加其他控件作为子控件。

就像是:

final Group group = new Group(parent, SWT.NONE);
group.setText("Details");

group.setLayout(new GridLayout(2, false));

Label label1 = new Label(group, SWT.NONE);
label1.setText("Label 1");

Text text1 = new Text(group, SWT.LEAD | SWT.BORDER);
text1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

Label label2 = new Label(group, SWT.NONE);
label2.setText("Label 2");

Text text2 = new Text(group, SWT.LEAD | SWT.BORDER);
text2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

关于java - 如何在边框内用必要的详细信息填充组SWT小部件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24861995/

10-09 20:35
查看更多