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
import org.eclipse.swt.SWT; |
Output will be displayed as:

After submitting the form, following message will be displayed in the message box:


If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Login Form in SWT
Post your Comment