我在放入ScrolledComposite
里面时遇到问题Group
- 它没有显示在Group
. ScrolledComposite
必须滚动Label
。
final private static Group group_netpbmOutput = new Group(shell, SWT.NONE);
final private static ScrolledComposite scroll_netpbmOutput = new ScrolledComposite(group_netpbmOutput, SWT.V_SCROLL | SWT.H_SCROLL);
final private static Label labelImage_netpbmOutput = new Label(scroll_netpbmOutput, SWT.BORDER);
//init Group
group_netpbmOutput.setLayout(new FillLayout());
formData = new FormData(((FormData)group_options.getLayoutData()).width, 200);
formData.top = new FormAttachment(group_options, 50, SWT.BOTTOM);
formData.left = new FormAttachment(group_options, 0, SWT.LEFT);
group_netpbmOutput.setLayoutData(formData);
group_netpbmOutput.setFont(font_group);
group_netpbmOutput.setText("Netpbm output");
//init Label
labelImage_netpbmOutput.setBackgroundImage(new Image(...));
//init ScrollComposite
scroll_netpbmOutput.setLayout(new FillLayout());
scroll_netpbmOutput.setContent(labelImage_netpbmOutput);
编辑:对巴兹回答的反应
那行得通,但是...图片以这种方式显示(应该只有一个'stackoverflow'):
final private static Group group_netpbmOutput = new Group(shell, SWT.NONE);
final private static ScrolledComposite scroll_netpbmOutput = new ScrolledComposite(group_netpbmOutput, SWT.V_SCROLL | SWT.H_SCROLL);
final private static Label labelImage_netpbmOutput = new Label(scroll_netpbmOutput, SWT.BORDER);
group_netpbmOutput.setLayout(new GridLayout());
formData = new FormData(((FormData)group_options.getLayoutData()).width, 200);
formData.top = new FormAttachment(group_options, 50, SWT.BOTTOM);
formData.left = new FormAttachment(group_options, 0, SWT.LEFT);
group_netpbmOutput.setLayoutData(formData);
group_netpbmOutput.setFont(font_group);
group_netpbmOutput.setText("Netpbm output");
labelImage_netpbmOutput.setBackgroundImage(new Image(...));
scroll_netpbmOutput.setLayout(new GridLayout(1, false));
scroll_netpbmOutput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scroll_netpbmOutput.setContent(labelImage_netpbmOutput);
scroll_netpbmOutput.setExpandHorizontal(true);
scroll_netpbmOutput.setExpandVertical(true);
scroll_netpbmOutput.setMinSize(labelImage_netpbmOutput.computeSize(SWT.DEFAULT, SWT.DEFAULT));