java - 在 Eclipse 中触发 gui 更新(表未按应有的方式扩展)

标签 java user-interface eclipse-plugin swt

我的 Eclipse 插件中有一个表格,当数据更改时,该表格不会垂直延伸。我执行了 viewer.refresh() 来显示新数据,但表格只显示一行。

如果我最小化窗口并恢复它,那么表将增长以显示所有行。与相同类型的 gui 重新布局相比,我需要调用什么来触发?

(表格位于 GridLayout 中,设置为双向增长)

最佳答案

您看到的问题是由于父级不知道子级何时需要更多空间而引起的。

您可以通过调用以下任一方法强制父级重新计算其布局(并询问子级所需的大小):

  • Composite.layout() :

    If the receiver has a layout, asks the layout to lay out (that is, set the size and location of) the receiver's children. If the receiver does not have a layout, do nothing.

  • Composite.layout(boolean) :

    If the receiver has a layout, asks the layout to lay out (that is, set the size and location of) the receiver's children. If the argument is true the layout must not rely on any information it has cached about the immediate children. If it is false the layout may (potentially) optimize the work it is doing by assuming that none of the receiver's children has changed state since the last layout. If the receiver does not have a layout, do nothing.

  • Composite.layout(boolean, boolean) :

    If the receiver has a layout, asks the layout to lay out (that is, set the size and location of) the receiver's children. If the changed argument is true the layout must not rely on any information it has cached about its children. If it is false the layout may (potentially) optimize the work it is doing by assuming that none of the receiver's children has changed state since the last layout. If the all argument is true the layout will cascade down through all child widgets in the receiver's widget tree, regardless of whether the child has changed size. The changed argument is applied to all layouts. If the all argument is false, the layout will not cascade down through all child widgets in the receiver's widget tree. However, if a child is resized as a result of a call to layout, the resize event will invoke the layout of the child. Note that a layout due to a resize will not flush any cached information (same as layout(false)).

关于java - 在 Eclipse 中触发 gui 更新(表未按应有的方式扩展),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24311642/

相关文章:

java - 三元运算符的编译错误

Python Tkinter 小窗口在主窗口之前弹出

java - 如何在 Java 中将 JButton 转换为 JToggleButton?

java - 如何使 GridLayout 行不相等

java - 在 Marvin 图像处理框架 Java 中绘制文本

java - 数组的匿名子类?我认为?不明白这个语法

java - 在同级模块之间共享动态生成的属性

java - 在 Android 中创建波形 UI

java - 自动展开 Eclipse 插件 jar

java - Eclipse TextEditorAction 如何知道当前文件位于哪个项目中?