2. Objective
On completion of this period, you would be
able to know
• Fundamentals of Windows
http://improvejava.blogspot.in/
2
3. Recap
In the previous class, you have leant
• Using delegation event model
• Handling keyboard events
• Handling Mouse events
• Adapter class
http://improvejava.blogspot.in/
3
4. Fundamentals of Windows
• The AWT defines windows according to a class
hierarchy that adds functionality and specificity with each
level
• The two most common windows are those derived from
– Panel
– Frame
• Much of the functionality of these windows is derived
from their parent classes
• A description of the class hierarchies relating to these
two classes is fundamental to their understanding
http://improvejava.blogspot.in/
4
5. Fundamentals of Windows contd..
• Fig. 61-1 shows the class hierarchy for Panel and Frame
Component
Container
MenuContainerInterface
Window Panel
Fig. 61.1 Class hierarchy of Panel and Frame
Frame
http://improvejava.blogspot.in/ 5
5
6. Component Class
• Component class is at the top of the AWT hierarchy
• Component is an abstract class that encapsulates all of
the attributes of a visual component
• All GUI components are subclasses of Component
• It defines over a hundred public methods that are
responsible for managing events
• A Component object is responsible for remembering the
current foreground and background colors and the
currently selected text font
http://improvejava.blogspot.in/ 6
7. Container Class
• The Container class is a subclass of Component
• It has additional methods that allow other
Component objects to be nested within it
• Other Container objects can be stored inside of
a Container
• A container is responsible for laying out any
components that it contains
• It does this through the use of various layout
managers
http://improvejava.blogspot.in/ 7
8. Panel Class
• The Panel class is a concrete subclass of
Container
• It doesn’t add any new methods; it simply
implements Container
• Panel is the superclass for Applet
• a Panel is a window that does not contain a title
bar, menu bar, or border
• Other components can be added to a Panel
object by its add( ) method
http://improvejava.blogspot.in/ 8
9. Window Class
• The Window class creates a top-level window
• A top-level window is not contained within any
other object
• It sits directly on the desktop
http://improvejava.blogspot.in/ 9
10. Frame Class
• Frame encapsulates what is commonly thought
of as a “window”
• It is a subclass of Window
• It has
– A title bar
– Menu bar
– Borders
– Resizing corners
http://improvejava.blogspot.in/ 10
11. Summary
• We have discussed
– The fundamentals of windows
– Frame class hierarchy
http://improvejava.blogspot.in/ 11
12. Quiz
1. The parent class of Frame class is
a) Panel
b) Container
c) Component
d) Window
http://improvejava.blogspot.in/ 12
13. Quiz contd...
2. Whether Frame class has title bar ?
a) True
b) False
http://improvejava.blogspot.in/ 13
14. Frequently Asked Questions
1. Explain the fundamentals of windows
2. Draw the class hierarchy of Frame class
http://improvejava.blogspot.in/ 14