当前位置: 代码迷 >> Eclipse >> swt 布局有关问题,简单的很,高手来看看吧
  详细解决方案

swt 布局有关问题,简单的很,高手来看看吧

热度:320   发布时间:2016-04-23 13:36:50.0
swt 布局问题,简单的很,高手来看看吧
在窗口SHELL里有个面板scomposite_main_top,scomposite_main_top 用了GridData 布局,设置了他的高,宽式自动填充的。现在我要得到他宽高值该怎么办
Java code
final ScrolledComposite scomposite_main_top = new ScrolledComposite(composite_main_body,SWT.NONE|SWT.V_SCROLL);        GridData gd_main_top = new GridData(GridData.FILL_HORIZONTAL|GridData.FILL_VERTICAL);        gd_main_top.heightHint=200;        scomposite_main_top.setLayoutData(gd_main_top);        scomposite_main_top.setBackground(color_mian_body);

谢谢了,希望能有人帮忙解决下

------解决方案--------------------
得到实例,get一下 swt API doc中有相关信息 ,仔细看看
------解决方案--------------------
Java code
int width = scomposite_main_top.getBounds().width ;iny height = scomposite_main_top.getBounds().height;
------解决方案--------------------
取parent shell的高宽不就行了?
------解决方案--------------------
我不敢确定,但很有可能composite设成自动填充以后,宽和高这两个属性就是0了。
getBound.width这类属性是用来限定composite的大小的(绝对坐标),但是自动填充使得composite的实际大小可变,比如在拖拉窗体的时候。

楼主要不把你想做什么效果也说说


  相关解决方案