我正在開發一個基於eclipase的插件,其中創建了一個應用程序(使用SWT)。有兩類: RunAction.java
它由run()
,dispose()
和init()
方法和Sample.java
組成,它由具有Label小部件的示例應用程序組成。現在,當我通過將它作爲Eclipse應用程序運行來測試應用程序時,在沒有標籤小部件的情況下顯示shell。 這是什麼問題?我與他人分享了代碼。啓動Eclipse RCP應用程序時不顯示Widgets
RunAction.java
public class RunWizardAction extends Action implements IWorkbenchWindowActionDelegate {
/** Called when the action is created. */
Sample samp=new Sample();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
public void init(IWorkbenchWindow window) {
}
/** Called when the action is discarded. */
public void dispose() {
}
/** Called when the action is executed. */
public void run(IAction action) {
//InvokatronWizard wizard= new InvokatronWizard();
new Thread(new Runnable(){
@Override
public void run() {
samp.sampleApp(shell);
}
}).start();
}
}
Sample.java(樣本函數)
public void sampleApp(Shell shell) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello");
JLabel lab=new JLabel("Hello World");
Label username_checkout=new Label(shell, SWT.BOLD);
username_checkout.setText("User Name");
Button button=new Button(shell,SWT.PUSH);
button.setText("push");
shell.open();
shell.setSize(270,270);
while (!shell1.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
oops shell1 is typo – 2013-04-04 13:18:09