Joh*_*ohn 0 java eclipse user-interface swt eclipse-plugin
我的Eclipse应用程序中有一个简单的swt GUI,如下所示:
它的实现非常简单:
// creating the label
Label label = new Label(composite, SWT.NONE);
label.setText("Label");
// creating the input field
Text text = new Text(composite, SWT.BORDER);
gridData.horizontalAlignment = SWT.FILL;
gridData.grabExcessHorizontalSpace = true;
text.setLayoutData(gridData);
Run Code Online (Sandbox Code Playgroud)
我想在标签和输入元素之间添加一个按钮,以便用户可以获得有关在字段内添加内容的其他帮助.
它可以是帮助按钮,也可以只是一个显示鼠标悬停信息的图标.
我该如何实现?我将不胜感激任何帮助!
执行此操作的众多方法之一是使用信息字段修饰.
就像是:
Text text = new Text(composite, SWT.BORDER);
FieldDecorationRegistry decRegistry = FieldDecorationRegistry.getDefault();
FieldDecoration infoField = decRegistry.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
ControlDecoration decoration = new ControlDecoration(text, SWT.TOP | SWT.LEFT);
decoration.setImage(infoField.getImage());
decoration.setDescriptionText("Info decoration text");
GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
// Space for decoration image
gridData.horizontalIndent = decRegistry.getMaximumDecorationWidth();
text.setLayoutData(gridData);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1064 次 |
| 最近记录: |