Series: AWT Components

Java Front end components like buttons etc explained in simple terms.

TextField Applet Adding Two Numbers

After validating user name and password using TextField in an application (application extends frame), let us rewrite the same program using applets but with a different functionality. We take two numbers from the user and display the sum of two numbers. The following program comes with 3 text fields. In two text fields, user enters …

TextField Applet Adding Two Numbers Read More »

Java make Button Invisible

After learning GUI creation through 8 steps, for more command over button event handling, apart this one, another two programs are given – Changing Button Label and Making Button Enabled. Example on Java make Button Invisible In the following program, three buttons are created with labels Red, Green and Blue. When Red button is clicked, …

Java make Button Invisible Read More »

TextField User Name Password Validation

After Button, the most used AWT component is TextField. TextField is useful to take input from the user and also to display output to the user by the programmer. User can write and edit the text in the TextField. Programmatically, the TextField can be made non-editable. Pressing Enter key generates ActionEvent and can be handled …

TextField User Name Password Validation Read More »

Radio button and Radio button group

1. What is Radio button? Infact, there is no radio button class in Java. Radio buttons are nothing but checkboxes only but grouped as one unit. 2. What the advantage of grouping checkboxes? Once grouped, in the group if one checkbox is selected, the other gets automatically deselected. This is the only advantage. Sometimes, it …

Radio button and Radio button group Read More »

Java Component Preferred Size

To develop user friendly and good look environment, the layout of the components in a container is very important to the programmer like the selection of colors and fonts for graphics. The user should feel free and comfortable to stay some time in GUI. To give attractive graphical user interface design, the AWT package comes …

Java Component Preferred Size Read More »

Java AWT Panels

Java AWT Panels play a very important role in layout management. Panels in combination with layout managers render the desired layout to the programmer. Following hierarchy gives the place of Panel in AWT API. java.lang.Object –> java.awt.Component –> java.awt.Container –> java.awt.Panel –> java.applet.Applet Properties of Java AWT Panels As you can see from the hierarchy, …

Java AWT Panels Read More »

Java TextField Methods

This is second program on TextField, first being User Name Password Validation (applet version is also available). The methods like setColumns(), setText() and setFont(), getColumns() and getText() are used to set and get the properties. Example on using Java TextField Methods import java.awt.*; public class TextFieldProperties extends Frame { TextField tf1, tf2, tf3; public TextFieldProperties() …

Java TextField Methods Read More »

Java AWT Radio Buttons Applet GUI

Radio buttons give a more user friendly environment when the user has to select only one option among many. There is no radio button class in java.awt package. Radio buttons are a group of checkboxes grouped as one unit. In the unit, if another radio button is selected, the earlier gets automatically deselected. Because radio …

Java AWT Radio Buttons Applet GUI Read More »

Java AWT List Multiple Single Selection

List permits the selection of multiple items (Choice allows single selection). Programmer prefers List when checkboxes are many to display (in case of Choice, when radio buttons are many to display). List adds a scrollbar with which items can be scrolled and seen. List can be designed for single selection or multiple selection (Java AWT …

Java AWT List Multiple Single Selection Read More »