如何在 Ext GWT (GXT) 中强制重绘/重新布局?

发布于 2024-10-14 00:56:04 字数 736 浏览 2 评论 0原文

在 GXT 中,我有一个控件,其中添加了一个重要面板到底部组件,基本上是这样的:

public class SamplePanel extends ContentPanel {

ContentPanel panel = new ContentPanel();    

public SamplePanel() {
    setBottomComponent(panel);
}

public void setVisible(boolean isVisible) {
    panel.setVisible(isVisible);
}

该面板被设置为“底部组件”,因为它需要保持在小部件的底部并且始终可见。

问题是,虽然面板的可见性可以正确切换,但“底部组件”区域不会调整大小以变小并适合底部区域的新尺寸。

但是,我注意到当我用鼠标手动更改小部件的大小时,底部区域的大小确实会调整。

有没有什么方法可以以编程方式强制重绘/重绘/重新布局...任何可以让底部组件更改以反映其内容的新大小的内容?

我已经尝试了所有这些,但它们不起作用:

public void setVisibility(boolean isVisible) {
        panel.setVisible(isVisible);
        doLayout(true);
        recalculate();
        repaint();
    }

谢谢

In GXT, I've got a control with an important panel added to the bottom component, basically like this:

public class SamplePanel extends ContentPanel {

ContentPanel panel = new ContentPanel();    

public SamplePanel() {
    setBottomComponent(panel);
}

public void setVisible(boolean isVisible) {
    panel.setVisible(isVisible);
}

The panel is being set as the "bottom component" because it needs to stay at the bottom of the widget and viewable at all times.

The problem is, while the visibility of the panel toggles correctly, the 'bottom component' area doesn't resize to become smaller and fit the new dimensions of the bottom area.

However, I've noticed that the bottom area does resize when I manually change the size of the widget with the mouse.

Is there any way to programatically force a redraw/repaint/re-layout... anything to have the bottom component change to reflect the new size of its contents?

I've tried all of these and they don't work:

public void setVisibility(boolean isVisible) {
        panel.setVisible(isVisible);
        doLayout(true);
        recalculate();
        repaint();
    }

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

缘字诀 2024-10-21 00:56:04

在最后的gxt中你可以这样做。

this.layout(true);

否则,您可以触发 Events.Resize 事件。

In the last gxt you can do.

this.layout(true);

Otherwise you can fire an Events.Resize event.

温馨耳语 2024-10-21 00:56:04

我不了解 GXT,但在 GWT 中,我会在面板上使用 force()forceLayout() 方法之一。也许有一个类似的 API 可以做到这一点!

HTH。

I don't know about GXT, but in GWT I would use one of the force() or forceLayout() methods on my panel. Perhaps there is a similar API for doing that!

HTH.

泛泛之交 2024-10-21 00:56:04

您是否尝试过使用 ConentPanelsetLayoutOnChange() 方法?

Have you tried using the setLayoutOnChange() method of the ConentPanel?

在梵高的星空下 2024-10-21 00:56:04

我建议看看这个:
http://davidmaddison.blogspot.com/2008/12/gwt-rendering -process.html

您可以尝试做的是将Listeners添加到Panel并尝试在那里调用panel.layout()

I would suggest looking at this:
http://davidmaddison.blogspot.com/2008/12/gwt-rendering-process.html

What you can try to do is addListeners to the Panel and try calling panel.layout() there

浪漫之都 2024-10-21 00:56:04

这篇文章声称顶部和底部组件不参与布局一旦面板被渲染并建议手动解决方法(使用 RowLayout)或手动设置面板的大小。

考虑从父级查找尺寸并调用 onResize(width, height)

This post claims that the top and bottom components to not participate in layout once the panel has been rendered and suggests a manual workaround (using RowLayout) or manually setting the size of the panel.

Consider finding the sizes from the parent and calling onResize(width, height)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文