Font Awesome Icons

Tutorial

AWT Basic Term

Container

The Container is a component in AWT that can contain another components like buttons, textfields, labels etc. The classes that extends Container class are known as container such as Frame, Dialog and Panel.

 
 

Window

The window is the container that have no borders and menu bars. You must use frame, dialog or another window for creating a window.

 

Component class and its sub classes

Component class is an immediate sub class of the Object. The other immediate sub classes include Label, Button, Checkbox, Choice, List, Canvas, Scrollbar and TextComponent.

 

 

Window class

A window in AWT is a container represents a top-level window that doesn’t have a title bar (so it doesn’t have close, minimize, maximize buttons), menu bar. This sits on the desktop directly and has a BorderLayout by default.

 

Frame class

It is a sub class of Window class which has a title bar, menu bar, borders and is re-sizable with border layout by default. This is what we use in our programs to create windows.

 

Panel class 

It is a sub class of the Container class. It is a border less window that doesn’t contain any title bar or menubar. usually added to another container like the Frame. The main purpose of a panel is to group components. It comes with a default FlowLayout.

 
 

Label class

A label is an informatory GUI component that typically describes another component. For example, you see a label Username side of a username field to tell you that the textfield is for typing username.

 
 

Button class

A Button is the most common GUI control that lets you click on it do some action. You might already have seen it a lot of times, in OK and Cancel buttons.

 
 

TextField class

A TextField can contain a single row text. It is mostly used for single line data. You already have seen it in lot of username fields and even in the subscribe field in the blog sidebar. It is a sub class of TextComponent

 
 

TextArea class

A TextArea can contain multiple rows of text. You might have seen it in Notepad, that’s where you write text. As it contains multiple rows and columns, it contains scrollbars.

 
 

Checkbox class

A checkbox allows user to check or un check an option. Users can check multiple checkboxes. However, you can also use checkbox as a radio button (which restricts user to select only one out of various checkboxes) if several checkboxes are added to a group. 

 
 

Choice class

A Choice allows user to choose an item from a list of similar items. It is a drop down menu also called as a combo box (in swing) and only one item is visible before drop down.

 

 List class

A List unlike a Choice allows user to select multiple items, however there is also an option to restrict to a single selection. But a list looks different, all items are visible in the List.

 
 

Working with Menus

A MenuBar is a component that contains menus. A Menu contains MenuItems and other menus. If A menu contains B Menu then B Menu is said to be a sub menu of A Menu.

 
 

CheckboxMenuItem class

A CheckboxMenuItem is a MenuItem that can be checked or un-checked. You might have encountered it in Notepad > Format > Wordwrap

 
 

Dialog class

A dialog is a window with a title bar but with no minimize or maximize options. It is a direct sub-class of Window and comes with default BorderLayout. You can also remove the title bar as you can in Frame. Also, a dialog can be constructed with a parent, typically a Frame or another dialog.

Dialogs are divided into types, Modal and Modeless (default). A modal dialog blocks user input of top-level windows of the dialog (i.e. its parents, but not its children) while a modeless dialog doesn’t. Like the Frame, dialogs can generate WindowEvent.

 
 

FileDialog class

A FileDialog is a dialog that lets user select a file either for opening or saving. You can see it when you click open/save as in Notepad. It is modal by default, which means that it blocks user input until user selects a file or closes it.