0
我正在做一個教程,並且我自己添加了一些標籤來測試它,並且拋出一些東西來獲得更好的抓握效果和labellast。 setLocation似乎只是做沒什麼labellast,標籤的位置不會改變......從eclipse學習SWT開始,爲什麼這個標籤不會改變位置
這裏是我的源:
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(250, 350);
Label label1 = new Label(shell, SWT.BORDER);
label1.setText("Hello World!");
label1.setSize(100, 20);
label1.setLocation(30, 30);
Text text1 = new Text(shell, SWT.BORDER);
text1.setText("Type Here");
text1.setTextLimit(50);
text1.setBounds(10, 10, 200, 20);
text1.setLocation(30, 60);
Label hello = new Label(shell, SWT.BORDER);
hello.setText("type what the top line says.");
hello.setSize(190, 20);
hello.setLocation(30, 90);
Label sep1 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL
| SWT.SHADOW_IN);
sep1.setBounds(30, 60, 100, 120);
Label label2 = new Label(shell, SWT.NONE);
label2.setText("World Hello");
label2.setSize(100, 20);
label2.setLocation(30, 150);
Label sep2 = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
sep2.setBounds(30, 120, 100, 20);
Label label3 = new Label(shell, SWT.NONE);
label3.setSize(100, 20);
label3.setLocation(30, 210);
label3.setBackground(new Color(display, 200, 111, 50));
label3.setText("World World.");
Text text2 = new Text(shell, SWT.NONE);
text2.setEchoChar('*');
text2.setBounds(10, 50, 200, 20);
text2.setText("Password");
text2.setLocation(30, 250);
text2.setEditable(false);
Label labellast = new Label(shell, SWT.NONE);
labellast.setLocation(30, 300);
labellast.setText("You cant edit that^^^");
labellast.setBounds(10, 50, 200, 20);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
謝謝!本教程在這方面有點誤導,因爲它一直告訴我有一個設置的位置和每一個的界限......我很困惑,所有四個參數setBounds做了什麼。 – poetzmij