小编Aar*_*ger的帖子

在调整Shell大小之前不显示Java SWT Text控件

我在这里的尝试基本上是在程序运行时热切换组件。如果用户按下按钮,则作为浏览器的控件将变成文本控件。我使用一个控件指向浏览器,然后将其切换为指向Text控件(该控件在非显示外壳上画在屏幕外)但是,我遇到了一些问题。当前,当按下按钮时,浏览器消失,但在调整外壳大小之前,该位置没有任何显示。

以下是相关的代码段:

切换例程:

private void switchWindow(Control cont) {
    bottomPointer.setParent(offDraw);
    bottomPointer = cont;
    bottomPointer.setParent(outer);
    bottomPointer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    outer.redraw();
}
Run Code Online (Sandbox Code Playgroud)

创建对象的buttonListener:

class textSelectionListener implements SelectionListener {
    public void widgetSelected(SelectionEvent event) {
        Text bottomText = new Text(offDraw, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
        GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL |  GridData.VERTICAL_ALIGN_FILL);
        gd.grabExcessVerticalSpace = true;
        gd.grabExcessHorizontalSpace = true;
        bottomText.setLayoutData(gd);
        switchWindow(bottomText);
    }
Run Code Online (Sandbox Code Playgroud)

我的大小调整后的监听器:

outer.addListener (SWT.Resize,  new Listener () {
//add resize listener to    automatically resize both browsers
    public void handleEvent (Event …
Run Code Online (Sandbox Code Playgroud)

java swt resize screen

2
推荐指数
1
解决办法
4029
查看次数

标签 统计

java ×1

resize ×1

screen ×1

swt ×1