Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取以GWT为单位的面板宽度和高度_Gwt_Gwt2 - Fatal编程技术网

获取以GWT为单位的面板宽度和高度

获取以GWT为单位的面板宽度和高度,gwt,gwt2,Gwt,Gwt2,我想在画布上绘制一个渐变,并将其添加到AbsolutePanel,因此我需要AbsolutePanel的宽度和高度来定义渐变向量。但如果我将AbsolutePanel添加到RootLayoutPanel(通过DockPanel的north小部件,宽度设置为100%)并在之后调用方法setGradient(),则宽度和高度仍然为0。如何获取面板的尺寸?使用getOffsetWidth()和getOffsetHeight()方法。文件在这里: Gets the object's offset wid

我想在画布上绘制一个渐变,并将其添加到AbsolutePanel,因此我需要AbsolutePanel的宽度和高度来定义渐变向量。但如果我将AbsolutePanel添加到RootLayoutPanel(通过DockPanel的north小部件,宽度设置为100%)并在之后调用方法setGradient(),则宽度和高度仍然为0。如何获取面板的尺寸?

使用
getOffsetWidth()
getOffsetHeight(
)方法。文件在这里:

Gets the object's offset width in pixels. This is the total width of the object,
including decorations such as border, margin, and padding. 

这些方法是在UiObject中定义的,因此对于所有小部件都是通用的

也许你需要等到它出现。最容易检查的是添加一些按钮,并在按下按钮时进行渐变。如果它可以工作,那么您应该设置一些超时,或者在“some”事件处理程序中运行渐变代码(可能是onload)。您还可以添加Window.addResizeHandler()以在调整窗口大小时重新计算渐变。好的,感谢您提供的信息,我猜我在获取维度时会遇到问题,现在改为CSS3渐变:)