Интересно, но во многих местах указаны неверные примеры работы с диалоговыми окнами SWT!
То модальность начинает странно вести себя, то модальное окно образует свою иконку на TaskBar!
То модальность начинает странно вести себя, то модальное окно образует свою иконку на TaskBar!
/**
*
*/
package com.sitronics.swt;
/**
* @author NBochkarev
*
*/
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class SWTDialog extends Dialog
{
Object result;
Shell shell;
private Composite composite_1;
private Label label;
public SWTDialog(Shell parent, int style)
{
super(parent, style);
}
public SWTDialog(Shell parent)
{
this(parent, 0);
}
protected void createContents()
{
shell.setSize(812, 590);
shell.setText("Caption");
shell.setLayout(new FormLayout());
composite_1 = new Composite(shell, SWT.NONE);
FormData fd_composite_1 = new FormData();
fd_composite_1.bottom = new FormAttachment(0, 52);
fd_composite_1.left = new FormAttachment(0);
fd_composite_1.right = new FormAttachment(100);
fd_composite_1.top = new FormAttachment(0);
composite_1.setLayoutData(fd_composite_1);
label = new Label(composite_1, SWT.NONE);
label.setBounds(73, 10, 427, 38);
label.setText("Hello world!");
}
public Object open()
{
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE | SWT.MAX | SWT.MIN);
// Your code goes here (widget creation, set result, etc).
createContents();
shell.open();
Display display = parent.getDisplay();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
return result;
}
}