< Day Day Up > |
Recipe 9.1 Creating Message Boxes9.1.1 ProblemYou need to send a message to the user and/or get a little feedback from the user. 9.1.2 SolutionUse the SWT MessageBox class to create a message box, and check the return value from its open method to determine which button the user clicked. 9.1.3 DiscussionHere are the MessageBox class's methods:
You create a message box by passing the current shell to the MessageBox constructor, as well as the style you want to use: MessageBox(Shell parent, int style). Here are some common styles to use:
You use the message box's open method to display it; when the message box is closed, compare this method's int return value to one of the preceding styles such as SWT.YES, SWT.NO, or SWT.CANCEL to determine which button was clicked. |
< Day Day Up > |