我正在开发一个基于 eclipase 的插件,我在其中创建了一个应用程序(使用 SWT)。有两个类,即;RunAction.java
它由run()
、dispose()
和init()
方法组成,并且Sample.java
由带有标签小部件的示例应用程序组成。现在,当我通过将应用程序作为 Eclipse 应用程序运行来测试应用程序时,只会显示没有标签小部件的外壳。问题是什么?我正在分享代码。
运行动作.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();
}
}
}