| Display Class Dispose method [message #659664] |
Tue, 15 March 2011 01:38  |
Dharam Messages: 18 Registered: December 2010 |
Junior Member |
|
|
Hi!!
I have created RenameDialog class by subclassing Dialog class as shown below. (necessary only)
public class RenameDialog extends Dialog{
protected RenameDialog(Shell parentShell) {
super(parentShell);
setShellStyle(getShellStyle() | SWT.SHELL_TRIM);
}
protected void configureShell(Shell newShell)
{
super.configureShell(newShell);
newShell.setText("Rename Dialog");
newShell.setSize(500,150);
}
protected Control createDialogArea(Composite parent)
{}
}
When I am running this using code shown below, on closing of dialog, dialog disappears but disposing of display doesn't happen.
public class RenameDialogTest {
public static void main(String[] args) {
Display display=new Display();
Shell shell=new Shell(display,SWT.BORDER | SWT.TITLE);
RenameDialog dialog=new RenameDialog(shell);
if(dialog.open()==Window.OK)
System.out.println("OK");
while(!shell.isDisposed())
{
if(!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
}
On above code if I remove, if(!display.readAndDispatch()){..}, it works fine. Could u please explain me the exact funda of this method?
Thanks
|
|
|