AWT Components in Java

The Abstract Window Toolkit (AWT) is Java’s original platform-dependent windowing, graphics, and user-interface widget toolkit preceding Swing.AWT Components in Java

Java AWT Adapters

Java AWT Adapters are abstract classes from java.awt.event package introduced with JDK 1.1. Adapter classes make event handling simple and easy. Adapters usage replaces the listeners; adapters make event handling easy to the programmer. Every listener that includes more than one abstract method has got a corresponding adapter class. The advantage of adapter is that …

Java AWT Adapters Read More »

Draw Smiley Face Java Nested Panels

1. Creating Smiley Face This tutorial, "Draw Smiley Face Java Nested Panels", gives command over graphics to a novice. Fill ovals and arc are arranged in such way it looks smiley face. For beautification, a background color of pink (predefined color) is given. Example on Smiley Face import java.awt.*; public class SmileyFace extends Frame { …

Draw Smiley Face Java Nested Panels Read More »

Java No Layout Manager setBounds()

We know earlier in "Java Layout Managers" that two styles of placing components in containers – pixel format and position format. Now let us discuss clearly what pixel format is and how to place a component in terms of pixels. We also know earlier, the default layout manager for Frame is BorderLayout and for Panel …

Java No Layout Manager setBounds() 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 »

Java TextArea Multiple Lines Text

Java TextArea overcomes the limitation of TextField and is used to display or take input in multiple lines of text. Following list illustrates the limitations. Differences between TextField and TextArea TextField displays only one line of text of any length. TextArea displays multiple lines of text of any length. TextField generates ActionEvent handled by ActionListener …

Java TextArea Multiple Lines Text 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 AWT Listeners

Java AWT Listeners are a group of interfaces from java.awt.event package. Listeners are capable to handle the events generated by the components like button, choice, frame etc. These listeners are implemented to the class which requires handling of events. public class ButtonDemo1 extends Frame implements ActionListener The class ButtonDemo1 implements ActionListener as ButtonDemo1 includes some …

Java AWT Listeners Read More »

Java Choice Replacement Radio Buttons

Choice, another GUI component from the toolkit of classes of java.awt. Choice presents a pull-down menu. Choice is a replacement to radio buttons. Choice is chosen when radio buttons are many to display. Choice is popularly known as Combo box in other GUI environments. Choice, like radio buttons, allows selecting only one option among many. …

Java Choice Replacement Radio Buttons 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 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 Create Font Object

Important text can be made eye-catching by displaying in attractive fonts. A font represents a combination of a font name (like Monospaced), font style (like bold) and font size (like 20). Following is the class signature public class Font extends Object implements Serializable The Font constructor takes three parameters to create a Font object. Font …

Java AWT Create Font Object Read More »