To perform better validations, we must use Regular Expressions (REGEX).
Here, we check if the username is section.io, and the password is 123. Imlementing an action event listener class with conditional public void actionPerformed (ActionEvent e ) To begin with, we import the Java GUI packages: Having understood a little about various Java GUI components. The English characters will be replaced by any other special character. Note that, password text fields do not show the original characters. JTextField is a lightweight component that allows the editing a single line of text. A label provides a keyboard alternative as a convenience for a nearby component. JLabelsĪ display area for a short text string or an image, or both. It contains a title bar, menu bar, borders, and resizing corners. The size of the frame includes any area designated for the border.įrame encapsulates a window. JFrameĪ Frame is a top-level window with a title and a border. JPanel class covers the entire space or a window where we attach the component to visualize it along with other panels. In the example above, we declared a button as the variable name, JButton as the name of the class that holds the button component in the AWT package, and Login as the text that appears on the button.
Variables also hold GUI components like labels, checkboxes, text fields, frames, panels, and buttons.
In this tutorial, we will learn how to design a simple user login page like this: It provides a better and richer set of GUI components with native or cross-platform accessibility that makes the application look the same on different windows. Swing: Swing is a set of APIs containing GUI components used for creating Applications. Since then, Swing has remained the primary Java GUI technology.Ībstract Window Toolkit (AWT): AWT is a set of APIs used to create a GUI for Java applications. Later, it was replaced by Swing in Java SE 1.2. Java’s original GUI library was called Abstract Window Toolkit (AWT). Components such as labels, text fields, buttons, checkbox, JPanel, JFrame on the screen. GUIs offer a visual display of components. Java provides a rich set of libraries to create GUIs in a platform-independent way. In this article, we will learn how to build a simple GUI using Java. Graphical User Interfaces were introduced in reaction to the perceived steep learning curve of Command-Line Interfaces (CLIs).