有没有办法在 SWT 中创建右对齐的多行文本字段而不应用 SWT.WRAP 样式?我需要在文本字段中设置水平滚动条,当使用 WRAP 时该滚动条会消失。
最佳答案
只需使用SWT.MULTI | SWT.RIGHT
作为 Text
的样式:
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Text text = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.RIGHT);
text.setText("First line\nsecond line");
shell.open();
shell.pack();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
看起来像这样:
关于java - 在swt中创建右对齐的多行文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48926672/