如何在 Ext GWT (GXT) 中强制重绘/重新布局?
在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在最后的gxt中你可以这样做。
否则,您可以触发 Events.Resize 事件。
In the last gxt you can do.
Otherwise you can fire an Events.Resize event.
我不了解 GXT,但在 GWT 中,我会在面板上使用
force()
或forceLayout()
方法之一。也许有一个类似的 API 可以做到这一点!HTH。
I don't know about GXT, but in GWT I would use one of the
force()
orforceLayout()
methods on my panel. Perhaps there is a similar API for doing that!HTH.
您是否尝试过使用
ConentPanel
的setLayoutOnChange()
方法?Have you tried using the
setLayoutOnChange()
method of theConentPanel
?我建议看看这个:
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
这篇文章声称顶部和底部组件不参与布局一旦面板被渲染并建议手动解决方法(使用 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)