繁体   English   中英

样式化文本setText性能差

[英]Styled Text setText have bad perfomance

我对StyledText没什么问题。 当我使用setText()方法并且文本很长时,我必须等待几秒钟以呈现该文本。 有什么方法可以用来加快显示此文本的速度?

您可以实现的唯一优化是将setText() 放入 Job Runnable以不阻塞UI。

除此之外,它是SWT的API限制。

其他建议:

  • 提交错误/功能请求
  • 搜索一个StyledText ,尽管显然不存在
  • 重新考虑您的程序。 您没有备份计划吗? 性能至关重要吗?


    编辑:

    @ greg-449

     /** * * @author ggrec * */ public class Test { public static void main(final String[] args) { new Test(); } private Test() { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new GridLayout(1, false)); final Button button = new Button(shell, SWT.PUSH); button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); button.setText("Press me"); final StyledText text = new StyledText(shell, SWT.NONE); text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { text.setText("*put very long text here*"); } }); } }); shell.setSize(1000, 1000); shell.open(); while (!shell.isDisposed()) { if ( !display.readAndDispatch() ) display.sleep(); } display.dispose(); } } 
  • 暂无
    暂无

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM