我想将图像添加到最小值和最大值。
扫描仪将有两个图标+和 - 以及 - 区域中的文本和加号区域中的文本
的想法 例如,缩小( - 图标).............放大(+图标)
如何添加图片?
final Scale scale = new Scale (fComposite, SWT.BORDER);
Rectangle clientArea = fComposite.getClientArea ();
scale.setBounds (clientArea.x, clientArea.y, 200, 64);
scale.setMaximum (4);
scale.setPageIncrement (1);
scale.setSelection(4);
scale.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
.....
}
});
由于
答案 0 :(得分:1)
SWT不支持此功能。
但是,您只需将Label
/ CLabel
与Image
放在Scale
的两边:
public static void main(String[] args)
{
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, false));
shell.setText("StackOverflow");
Composite scaleComp = new Composite(shell, SWT.NONE);
scaleComp.setLayout(new GridLayout(3, false));
CLabel leftImage = new CLabel(scaleComp, SWT.RIGHT_TO_LEFT);
leftImage.setText("Left");
leftImage.setImage(display.getSystemImage(SWT.ICON_ERROR));
leftImage.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, true));
final Scale scale = new Scale (scaleComp, SWT.NONE);
scale.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
scale.setMaximum (4);
scale.setPageIncrement (1);
scale.setSelection(4);
CLabel rightImage = new CLabel(scaleComp, SWT.NONE);
rightImage.setText("Right");
rightImage.setImage(display.getSystemImage(SWT.ICON_INFORMATION));
rightImage.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, true));
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
看起来像这样: