【发布时间】:2020-10-06 20:28:38
【问题描述】:
我正在尝试使用 SWT 标签/Clabel 显示我的字符串中的 & 但是它们都忽略 & 字符下面是可以重现此问题的相同代码
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class LabelDemo {
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setLayout(new FillLayout());
Label label=new Label(shell, SWT.BORDER);
label.setText("text &the label");
// label.setImage(new Image(display,"yourFile.gif"));
shell.open();
// Set up the event loop.
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
// If no more entries in event queue
display.sleep();
}
}
display.dispose();
}
}
我在这里做错了吗。任何线索都会有所帮助。
【问题讨论】: