0
我对SWT编程颇为陌生。我有一个GridLayout
。当我第一次启动GUI时,它只在左上角显示一个Button
。如果我调整它的大小(使窗口变大或变小),我就得到了我想要的GUI。我修改了构造函数和open()
方法,但是我所做的每个更改都没有改变。在swt中调整大小问题
// constructor
public MyGuiApp(){
super();
shell = new Shell();
shell.setSize(250, 300);
// the open method
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.setLayout(new GridLayout(2,true));
// instantiation
public static void main(String args[]) {
try {
MyGuiApp window = new MyGuiApp();
window.open();
您能否发布完整的代码? – Baz
尝试在打开外壳之前设置布局。 –
好的建议 - 我需要做的是从构造函数中移动一些初始化,并打开createContents()方法。 – brifer