Professional Documents
Culture Documents
Dialog box
panel Applet class is used
to run programs
Panel class does not that run in a web
have a title, menu or browser.
border.
Applet window
c. layout manager
i. An object that defines how the components in a
container will be arranged.
ii. You don’t see the Layout Manager in an interface,
but you definitely see the results of its work on
the look and feel of your GUI.
The JavaTM Foundation class (JFC) provides two
frameworks for building GUI based applications
a. Abstract Windowing Toolkit (AWT)
b. Swings
Explain the AWT Hierarchy
Explain the AWT Hierarchy
• The Java AWT (Abstract Window Toolkit) contains the
fundamental classes used for constructing GUIs.
• The abstract Component class is the base class for the AWT.
• Many AWT classes are derived from it. These are the old AWT
components that are no longer in use.
• Some of the AWT classes derived from Component are
Button, Canvas, and Container.
• The JComponent class is derived from Container and is one of
the base classes of Swing.
• The JFrame class is derived from the AWT Frame class. It is
usually the main container for a GUI application.
• The JApplet class is derived from the AWT Applet class and is
used for modern applets.
Explain the AWT Hierarchy
COMPONENT
a) Component is an abstract class.
b) All other classes shown above are non-abstract
(concrete).
c) Component class is superclass of all the non-menu
related user interface classes.
d) It provides support for event handling, drawing of
components etc.
e) Some of the methods of Component class are :
i. void setForeground(Color c)
ii. void setBackground(Color c)
WINDOW
a) Window class represents a top-level window.
b) Both Window and Panel classes do not have title, menus
or borders.
c) The Window class is rarely used directly and its
subclasses Frame and Dialog are more common.
d) The pack method defined in Window class initiates the
layout manager of sub-components of the window.
FRAME
a) The Frame class is a subclass of the Window class. It is
used to create a GUI application window.
b) Frames have title bars, icons and menus.
Useful Methods if Components class
Method Description
public void add(Component c) insert a component on this
component
public void setSize(int width, set the size (width and height) of the
int height) component
• Label:
– Function:
• The object of Label class is a component for placing
text in a container.
• It is used to display a single line of read only text.
• The text can be changed by an application but a
user cannot edit it directly.
AWT Components
• Button:
– Function:
• The button class is used to create a labeled button
that has platform independent implementation.
• The application result in some action when the button
is pushed.
AWT Components
• TextField:
– Function:
• The object of a TextField class is a text component
that allows the editing of a single line text.
• It inherits TextComponent class.
AWT Components
• TextArea:
– Function:
• The object of a TextArea class is a multi line
region that displays text. It allows the editing of
multiple line text.
• It inherits TextComponent class.
AWT Components
• CheckBox:
– Function:
• The Checkbox class is used to create a checkbox.
• It is used to turn an option on (true) or off (false).
• Clicking on a Checkbox changes its state from "on"
to "off" or from "off" to "on".
AWT Components
• ScrollPane:
– Function:
• The object of Scrollbar class is used to add
horizontal and vertical scrollbar.
• Scrollbar is a GUI component allows us to see
invisible number of rows and columns.
Next is Part II