SlideShare a Scribd company logo
Unit 3 Cont….
GUI Basics, Panels, Frames
Window Fundamentals
Window Fundamentals Cont
• 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, which is used by applets, and those
derived from Frame, which creates a standard
application window.
Window Fundamentals Cont
• Component:
• At the top of the AWT hierarchy is the Component
class. Component is an abstract class that encapsulates
all of the attributes of a visual component. All user
interface elements that are displayed on the screen
and that interact with the user are subclasses of
Component. It defines over a hundred public methods
that are responsible for managing events, such as
mouse and keyboard input, positioning and sizing the
window, and repainting. A Component object is
responsible for remembering the current foreground
and background colors and the currently selected text
font.
Window Fundamentals Cont
• Container:
• 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 (since they are themselves instances of
Component). This makes for a multileveled
containment system. A container is responsible
for laying out (that is, positioning) any
components that it contains
Window Fundamentals Cont
• Panel:
• The Panel class is a concrete subclass of Container. It doesn’t add
any new methods; it simply implements Container. A Panel may be
thought of as a recursively nestable, concrete screen component.
Panel is the superclass for Applet. When screen output is directed
to an applet, it is drawn on the surface of a Panel object. In essence,
a Panel is a window that does not contain a title bar, menu bar, or
border. This is why you don’t see these items when an applet is run
inside a browser. When you run an applet using an applet viewer,
the applet viewer provides the title and border. Other components
can be added to a Panel object by its add( ) method (inherited from
Container). Once these components have been added, you can
position and resize them manually using the setLocation( ), setSize(
), setPreferredSize( ), or setBounds( ) methods defined by
Component.
Window Fundamentals Cont
• Window:
• 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. Generally, you won’t create Window
objects directly. Instead, you will use a
subclass of Window called Frame, described
next.
Window Fundamentals Cont
• Frame:
• Frame encapsulates what is commonly thought of as a
“window.” It is a subclass of Window and has a title bar,
menu bar, borders, and resizing corners. If you create a
Frame object from within an applet, it will contain a
warning message, such as “Java Applet Window,” to the
user that an applet window has been created. This
message warns users that the window they see was
started by an applet and not by software running on
their computer. When a Frame window is created by a
stand-alone application rather than an applet, a normal
window is created
Working with Graphics
• Drawing Lines
void drawLine(int startX, int startY, int endX, int endY)
Drawing Rectangles
The drawRect( ) and fillRect( ) methods display an
outlined and filled rectangle, respectively. They are
shown here:
void drawRect(int top, int left, int width, int height)
void fillRect(int top, int left, int width, int height)
The upper-left corner of the rectangle is at top,left.
The dimensions of the rectangle are specified by width
and height.
Drawing Rectangles Cont..
• To draw a rounded rectangle, use drawRoundRect( ) or
fillRoundRect( ), both shown here:
• void drawRoundRect(int top, int left, int width, int height,
int xDiam, int yDiam)
• void fillRoundRect(int top, int left, int width, int height, int
xDiam, int yDiam)
• A rounded rectangle has rounded corners. The upper-left
corner of the rectangle is at top,left. The dimensions of the
rectangle are specified by width and height. The diameter of
the rounding arc along the X axis is specified by xDiam. The
diameter of the rounding arc along the Y axis is specified by
yDiam.
Drawing Ellipses and Circles
• To draw an ellipse, use drawOval( ). To fill an ellipse,
use fillOval( ). These methods are shown here:
• void drawOval(int top, int left, int width, int height)
• void fillOval(int top, int left, int width, int height)
• The ellipse is drawn within a bounding rectangle whose
upper-left corner is specified by top,left and whose
width and height are specified by width and height. To
draw a circle, specify a square as the bounding
rectangle.
Drawing Arcs
• Arcs can be drawn with drawArc( ) and fillArc( ), shown here:
• void drawArc(int top, int left, int width, int height, int startAngle,
int sweepAngle)
• void fillArc(int top, int left, int width, int height, int startAngle, int
sweepAngle)
• The arc is bounded by the rectangle whose upper-left corner is
specified by top,left and whose width and height are specified by
width and height. The arc is drawn from startAngle through the
angular distance specified by sweepAngle. Angles are specified in
degrees. Zero degrees is on the horizontal, at the three o’clock
position. The arc is drawn counterclockwise if sweepAngle is
positive, and clockwise if sweepAngle is negative. Therefore, to
draw an arc from twelve o’clock to six o’clock, the start angle would
be 90 and the sweep angle 180.
Working with Color
public void init()
{
setBackground(Color.cyan);
setForeground(Color.red);
}

More Related Content

Similar to unit3.3.pptx

Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
soumyaharitha
 
Gui programming
Gui programmingGui programming
Gui programming
manikanta361
 
Session4 applets
Session4   appletsSession4   applets
Session4 applets
Unit Nexus Pvt. Ltd.
 
JAVA Programming: Topic -AWT(Abstract Window Tool )
JAVA Programming: Topic -AWT(Abstract Window Tool )JAVA Programming: Topic -AWT(Abstract Window Tool )
JAVA Programming: Topic -AWT(Abstract Window Tool )
Navya Francis
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
Elizabeth alexander
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
aptechaligarh
 
Auto cad 2007-tutorial
Auto cad 2007-tutorialAuto cad 2007-tutorial
Auto cad 2007-tutorial
Syed Javeed
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in java
Abinaya B
 
Tutorials v10
Tutorials v10Tutorials v10
Tutorials v10
Walquer huacani calsin
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
PBMaverick
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
Sara Karaki
 
U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptx
madan r
 
Applet in java
Applet in javaApplet in java
Applet in java
Rakesh Mittal
 
Java chapter 7
Java chapter 7Java chapter 7
Java chapter 7
Abdii Rashid
 
Java applet
Java appletJava applet
Java applet
GaneshKumarKanthiah
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
srijavel
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, Listeners
Kalai Selvi
 
NX_CAD
NX_CADNX_CAD
NX_CAD
Barney Day
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
Prof. Dr. K. Adisesha
 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User Interface
Nick Pruehs
 

Similar to unit3.3.pptx (20)

Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
Gui programming
Gui programmingGui programming
Gui programming
 
Session4 applets
Session4   appletsSession4   applets
Session4 applets
 
JAVA Programming: Topic -AWT(Abstract Window Tool )
JAVA Programming: Topic -AWT(Abstract Window Tool )JAVA Programming: Topic -AWT(Abstract Window Tool )
JAVA Programming: Topic -AWT(Abstract Window Tool )
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
Auto cad 2007-tutorial
Auto cad 2007-tutorialAuto cad 2007-tutorial
Auto cad 2007-tutorial
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in java
 
Tutorials v10
Tutorials v10Tutorials v10
Tutorials v10
 
Java GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdfJava GUI Programming for beginners-graphics.pdf
Java GUI Programming for beginners-graphics.pdf
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptx
 
Applet in java
Applet in javaApplet in java
Applet in java
 
Java chapter 7
Java chapter 7Java chapter 7
Java chapter 7
 
Java applet
Java appletJava applet
Java applet
 
Applet and graphics programming
Applet and graphics programmingApplet and graphics programming
Applet and graphics programming
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, Listeners
 
NX_CAD
NX_CADNX_CAD
NX_CAD
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 
Unreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User InterfaceUnreal Engine Basics 05 - User Interface
Unreal Engine Basics 05 - User Interface
 

More from VeenaNaik23

Introduction-to-WFS.pptxIntroduction-to-WFS
Introduction-to-WFS.pptxIntroduction-to-WFSIntroduction-to-WFS.pptxIntroduction-to-WFS
Introduction-to-WFS.pptxIntroduction-to-WFS
VeenaNaik23
 
Fileoperations.pptx
Fileoperations.pptxFileoperations.pptx
Fileoperations.pptx
VeenaNaik23
 
wcmwiki.pptx
wcmwiki.pptxwcmwiki.pptx
wcmwiki.pptx
VeenaNaik23
 
web1.pdf
web1.pdfweb1.pdf
web1.pdf
VeenaNaik23
 
canvas.pptx
canvas.pptxcanvas.pptx
canvas.pptx
VeenaNaik23
 
HIV &AIDS AWARENESS 2022-23.pptx
HIV &AIDS AWARENESS 2022-23.pptxHIV &AIDS AWARENESS 2022-23.pptx
HIV &AIDS AWARENESS 2022-23.pptx
VeenaNaik23
 
Module3.11.pptx
Module3.11.pptxModule3.11.pptx
Module3.11.pptx
VeenaNaik23
 
Package.pptx
Package.pptxPackage.pptx
Package.pptx
VeenaNaik23
 
Mis
MisMis
Module 5.pptx
Module 5.pptxModule 5.pptx
Module 5.pptx
VeenaNaik23
 

More from VeenaNaik23 (10)

Introduction-to-WFS.pptxIntroduction-to-WFS
Introduction-to-WFS.pptxIntroduction-to-WFSIntroduction-to-WFS.pptxIntroduction-to-WFS
Introduction-to-WFS.pptxIntroduction-to-WFS
 
Fileoperations.pptx
Fileoperations.pptxFileoperations.pptx
Fileoperations.pptx
 
wcmwiki.pptx
wcmwiki.pptxwcmwiki.pptx
wcmwiki.pptx
 
web1.pdf
web1.pdfweb1.pdf
web1.pdf
 
canvas.pptx
canvas.pptxcanvas.pptx
canvas.pptx
 
HIV &AIDS AWARENESS 2022-23.pptx
HIV &AIDS AWARENESS 2022-23.pptxHIV &AIDS AWARENESS 2022-23.pptx
HIV &AIDS AWARENESS 2022-23.pptx
 
Module3.11.pptx
Module3.11.pptxModule3.11.pptx
Module3.11.pptx
 
Package.pptx
Package.pptxPackage.pptx
Package.pptx
 
Mis
MisMis
Mis
 
Module 5.pptx
Module 5.pptxModule 5.pptx
Module 5.pptx
 

Recently uploaded

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 

Recently uploaded (20)

MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 

unit3.3.pptx

  • 1. Unit 3 Cont…. GUI Basics, Panels, Frames
  • 3. Window Fundamentals Cont • 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, which is used by applets, and those derived from Frame, which creates a standard application window.
  • 4. Window Fundamentals Cont • Component: • At the top of the AWT hierarchy is the Component class. Component is an abstract class that encapsulates all of the attributes of a visual component. All user interface elements that are displayed on the screen and that interact with the user are subclasses of Component. It defines over a hundred public methods that are responsible for managing events, such as mouse and keyboard input, positioning and sizing the window, and repainting. A Component object is responsible for remembering the current foreground and background colors and the currently selected text font.
  • 5. Window Fundamentals Cont • Container: • 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 (since they are themselves instances of Component). This makes for a multileveled containment system. A container is responsible for laying out (that is, positioning) any components that it contains
  • 6. Window Fundamentals Cont • Panel: • The Panel class is a concrete subclass of Container. It doesn’t add any new methods; it simply implements Container. A Panel may be thought of as a recursively nestable, concrete screen component. Panel is the superclass for Applet. When screen output is directed to an applet, it is drawn on the surface of a Panel object. In essence, a Panel is a window that does not contain a title bar, menu bar, or border. This is why you don’t see these items when an applet is run inside a browser. When you run an applet using an applet viewer, the applet viewer provides the title and border. Other components can be added to a Panel object by its add( ) method (inherited from Container). Once these components have been added, you can position and resize them manually using the setLocation( ), setSize( ), setPreferredSize( ), or setBounds( ) methods defined by Component.
  • 7. Window Fundamentals Cont • Window: • 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. Generally, you won’t create Window objects directly. Instead, you will use a subclass of Window called Frame, described next.
  • 8. Window Fundamentals Cont • Frame: • Frame encapsulates what is commonly thought of as a “window.” It is a subclass of Window and has a title bar, menu bar, borders, and resizing corners. If you create a Frame object from within an applet, it will contain a warning message, such as “Java Applet Window,” to the user that an applet window has been created. This message warns users that the window they see was started by an applet and not by software running on their computer. When a Frame window is created by a stand-alone application rather than an applet, a normal window is created
  • 9. Working with Graphics • Drawing Lines void drawLine(int startX, int startY, int endX, int endY)
  • 10. Drawing Rectangles The drawRect( ) and fillRect( ) methods display an outlined and filled rectangle, respectively. They are shown here: void drawRect(int top, int left, int width, int height) void fillRect(int top, int left, int width, int height) The upper-left corner of the rectangle is at top,left. The dimensions of the rectangle are specified by width and height.
  • 11. Drawing Rectangles Cont.. • To draw a rounded rectangle, use drawRoundRect( ) or fillRoundRect( ), both shown here: • void drawRoundRect(int top, int left, int width, int height, int xDiam, int yDiam) • void fillRoundRect(int top, int left, int width, int height, int xDiam, int yDiam) • A rounded rectangle has rounded corners. The upper-left corner of the rectangle is at top,left. The dimensions of the rectangle are specified by width and height. The diameter of the rounding arc along the X axis is specified by xDiam. The diameter of the rounding arc along the Y axis is specified by yDiam.
  • 12. Drawing Ellipses and Circles • To draw an ellipse, use drawOval( ). To fill an ellipse, use fillOval( ). These methods are shown here: • void drawOval(int top, int left, int width, int height) • void fillOval(int top, int left, int width, int height) • The ellipse is drawn within a bounding rectangle whose upper-left corner is specified by top,left and whose width and height are specified by width and height. To draw a circle, specify a square as the bounding rectangle.
  • 13. Drawing Arcs • Arcs can be drawn with drawArc( ) and fillArc( ), shown here: • void drawArc(int top, int left, int width, int height, int startAngle, int sweepAngle) • void fillArc(int top, int left, int width, int height, int startAngle, int sweepAngle) • The arc is bounded by the rectangle whose upper-left corner is specified by top,left and whose width and height are specified by width and height. The arc is drawn from startAngle through the angular distance specified by sweepAngle. Angles are specified in degrees. Zero degrees is on the horizontal, at the three o’clock position. The arc is drawn counterclockwise if sweepAngle is positive, and clockwise if sweepAngle is negative. Therefore, to draw an arc from twelve o’clock to six o’clock, the start angle would be 90 and the sweep angle 180.
  • 14. Working with Color public void init() { setBackground(Color.cyan); setForeground(Color.red); }