如果文本包含选项卡,即'\ t',则SWT文本无法计算正确的宽度

时间:2012-02-09 07:14:47

标签: swt eclipse-rcp

请参阅以下代码段 未显示正确的宽度

Display display = new Display();
        Shell shell = new Shell( display );
        Text helloWorldTest = new Text( shell, SWT.BORDER |SWT.READ_ONLY);
        helloWorldTest.setText( "A\tB");
        helloWorldTest.pack();
        shell.pack(); //optional
        shell.open();
        while( !shell.isDisposed() )
        {
            if( !display.readAndDispatch() )
            {
                display.sleep();
            }
        }
        display.dispose();

在这里,我想使用带有可编辑false的文本。我还想显示上下文菜单,所以不能使用标签。

1 个答案:

答案 0 :(得分:0)

查看GC.textExtent(String string) ...

相关问题