SWT/JFace在窗口中打开新的窗口
程序员文章站
2022-06-01 22:16:35
...
打开提示/警告窗口:
dButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
MessageDialog.openInformation(getShell(), "提示/警告标题","提示/警告内容");
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
打开新窗口:
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Shell shell1=new Shell();
shell1.setText("新窗口");
GridLayout gridLayout=new GridLayout(2, false);
shell1.setLayout(gridLayout);
Label label2 = new Label(shell1, SWT.NONE);
label2.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
label2.setText("欢迎观看新窗口");
Button button=new Button(shell1, SWT.PUSH);
button.setText("这是一个按钮");
shell1.open();
}
});
注意SelectionListener()与SelectionAdapter()之间的区别
上一篇: 构建一个第三方登录平台