Problem Statement: To create a functional login GUI that enables users to enter login credentials and, upon verification, respond accordingly.
With the help of the CANCEL button, users can terminate login and exit the GUI.
Features:
- Individual input text fields for both username and password
- Cancel button to terminate login and exit application
- Login button to let user log-in
- Close application button (default swing button)
Taking this idea into code, a best way to create and place the components is to use
GridLayout
of 3 rows and 2 columns as per the UI Layout idea shown below
Column1 Column2 Row1-Label1 Row1-TextField1 Row2-Label2 Row2-TextField2 Row3-Button1 Row3-Button2
- Label1 - UserName
- Label2 - Password
- TextField1 - (Input) UserName
- TextField2 - (Input) Password
- Button1 - CANCEL
- Button1 - LOGIN