ダイアログシェルとしてJava SWTアプリケーションでシェルを作成しようとしています。「承諾」と「辞退」の2つのボタンがあります。ユーザーが30秒間ボタンをクリックしないと、シェルが自動的に破棄されます。このため、次のコードを試していますが、機能していません。アイデアや提案を使用して助けてください
public class ServiceRequestDialog extends Dialog {
public ServiceRequestDialog(Shell parent,String nameofrequestor) {
// Pass the default styles here
this(parent,SWT.NO_TRIM|SWT.ON_TOP|SWT.DIALOG_TRIM|SWT.APPLICATION_MODAL);
this.parent=parent;
nameofRequester=nameofrequestor;
}
public ServiceRequestDialog(Shell parent, int style) {
// Let users override the default styles
super(parent, style);
}
public Shell open() {
shell = new Shell(getParent(), getStyle());
shell.setText(getText());
shell.setLocation(parent.getLocation().x+190, parent.getLocation().y+215);
shell.setSize(279, 181);
shell.setLayout(new FormLayout());
......
shell.open();
Display display = getParent().getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
// Return the entered value, or null
try {
System.out.println("Thread Sleep");
Thread.sleep(15000);
dispose();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
return shell;
}
public void dispose(){
try {
if (shell != null) {
if (shell.isDisposed()==false) {
shell.dispose();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}