• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2. SWT Shells > Opening True Dialogs

2.7. Opening True Dialogs

ChildShellExample demonstrated how to open a child window within the confines of a parent window, but this is not the same as opening a true dialog. A dialog window is one that halts processing of code in the parent window until the user takes some action in the dialog. In ChildShellExample, the parent window code continued to execute even while the child window was opened. You can see the effect if you execute Example 2-8.

Example 2-8. Demonstrating the effect of opening a child on the parent

import org.eclipse.swt.widgets.*;

public class ChildShellExample {
    Display d = new Display( );
        
    ChildShellExample( )    {    
        Shell s = new Shell(d);
        s.setSize(500,500);
        s.open( );
        ChildShell cs1 = new ChildShell(s);
        System.out.println("Execution Continues");
        while(!s.isDisposed( )){
            if(!d.readAndDispatch( ))
                d.sleep( );
        }
        d.dispose( );

    }
}


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint