Swing: user interface programming
Swing is the part of java which is dedicated to the comunication with the user through windows.
The following window, for example, is the form we always complete with our user and password to login into an application, using the Swing library.
Inside this window we can identify three types of components:
- Labels: User and Password are labels.
- Text boxes: the two white boxes on the right of the labels are text boxes.
- Buttons: login and register are buttons.
There are also some predefined windows which are known as dialog boxes "Dialog":
This is a dialog box which displays a message; in this case "login failed". The following window is a dialog box to input data; the user in this case.
Let´s see how to develop this type of interfaces:
- How to use dialog boxes: showMessageDialog and showInputDialog
- User interface input data validation.
- Our first window; login example.
- We make the buttons work using Listeners.
- Anonymous inner class.