如何调整Shell子窗口的大小

时间:2012-05-25 23:49:50

标签: java resize swt childwindow

我有一个子窗口,包含一个表格,标签,组合,按钮,一行一行排列。形式不是有限的。有一个按钮用于添加额外的输入字段行。 目前正在运行 ...问题是添加新行时子窗口大小保持不变,但我希望它自动调整大小。

子窗口是标准的SWT shell

Shell ConstantEditWindow = new Shell(parent);

我有一个像这样的按钮:

addDesc.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {

            populateConstantMain(tariffConstantsOfType, descComp, descCompLayout, true);

            ConstantEditWindow.layout();

        }
    });

但是id不起作用:/子窗口不会调整大小;(

1 个答案:

答案 0 :(得分:0)

阅读本文:http://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html

和api:http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fwidgets%2Fpackage-summary.html

  • .layout()布局控件的子项
  • pack()会将接收器的大小调整为其首选大小。

同样惯例是java中的常量名称应为ALL_IN_CAPITAL。

相关问题