我正在尝试使用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();
}
}
我在这里做错什么了吗,任何线索都会有所帮助。