This section illustrates you how to create Login Form.
To create a login form in SWT, the Label class set the labels User Name and Password and Text class sets the text for the specified fields. The method shell.setLayout(new GridLayout(2, false)) sets the layout of the login form. The method setTextLimit(30) sets the limit on maximum number of characters. The method setEchoCharacter("*") sets the echo character for the password. A button is created to submit the form.
After submitting the button, if you haven't specify the username and password, an alert box will be displayed, which is provided by the class MessageBox. If you filled the required fields, the box shows the Welcome message along with the username.
Here is the code LoginForm.java
Output will be displayed as:
After submitting the form, following message will be displayed in the message box:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Login Form in SWT
Post your Comment