描述如下:
第一个对话框:名称为A (TDialog.java)
第二个对关闭按钮进行隐藏后的对话框:名称为B (TDialog1.java)
原本想用隐藏就可以解决问题的。
描述:点击 A中按钮,弹出B
存在的问题:点击A中按钮,弹出B 但是用鼠标点击B时,[color=darkred]B就自动隐藏了,没法进行操作。[/color]最小化eclipse后,桌面上显示 B对话框,并且可以对其进行操作。(代码见附件,demo不存在此问题)所以我想要[color=red]对关闭按钮进行置灰处理[/color],不知道这样处理后能不能变通解决对上述问题。或者有什么更好的方法进行处理?demo代码如下:
另外:怎样对B的消息区设置提示信息 [color=red]【 setMessage("Hello World!");//这样会报错】[/color]
package test;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class [color=red]TDialog [/color]extends TitleAreaDialog {
public TDialog(Shell parentShell) {
super(parentShell);
}
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(327, 253);
Button button = new Button(shell, SWT.NONE);
button.setBounds(18, 20, 153, 25);
button.setText("button");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TDialog1 tDialog = new TDialog1(shell);
tDialog.open();
}
});
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
package test;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class [color=red]TDialog1[/color] extends TitleAreaDialog {
final Display display = Display.getDefault();
final Shell shell = new Shell();
public TDialog1(Shell parentShell) {
super(parentShell);
[color=red] //setMessage("Hello World!");//怎样set message?[/color]
}
[color=green]@Override
protected int getShellStyle() {
return SWT.TITLE;// 隐藏关闭按钮,置灰时不需要这个方法
}[/color]
}