开发者

Cannot change Button size and location, with eclipse RCP?

I'm using eclipse RCP to develop a user interface. I created some buttons and I want to change their size and location.I used the methods setLocation() and setSize() but didn't get any result:

Composite top = new Composite(parent, SWT.NONE);
GridLayout layout1 = new GridLayout(2, true);
top.setLayout(layout1);
Bu开发者_运维问答tton buttonEdit = new Button(top, SWT.PUSH);
buttonEdit.setText("Edit");
buttonEdit.setLocation(10,10);
buttonEdit.setSize(50, 20);

Any idea? Thanks a lot


When you use a layout for the parent Composite - in this case a GridLayout - the location and (sometimes) size is disregarded and calculated by the layout.

If you really want to use absolute layout - which cannot be recommended - then simply remove top.setLayout(layout1).

If you find using a layout manager difficult, install the SWT Designer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜