我正在尝试在追加字符串后将SWT Text
的光标位置设置为末尾。我知道如何更改SWT StyledText
的光标位置,但不确定SWT Text
。如果您遇到这个问题并找到解决方案,请分享。
public static void main(String[] args)
{
Display d = new Display();
final Shell shell = new Shell(d);
shell.setLayout(new GridLayout(1, false));
Text text = new Text(shell, SWT.BORDER);
text.setText("Some random text here...");
text.setSelection(text.getText().length());
shell.pack();
shell.open();
while (!shell.isDisposed())
while (!d.readAndDispatch())
d.sleep();
}
这将把光标设置到末尾。