LESSON 4 Fundamentals of GUI Design - 20250410 - 143145 - 0000
LESSON 4 Fundamentals of GUI Design - 20250410 - 143145 - 0000
Fundamentals
of
GUI DESIGN
What is a Graphical User Interface (GUI)?
8. setFont(Font font)
sets the font used when drawing text
9. drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Draws a curved arc (part of an oval).
x, y: Top-left corner of bounding rectangle.
width, height: Size of bounding rectangle.
startAngle: Where the arc begins (in degrees).
arcAngle: How far the arc extends (in degrees).
Blue rectangle
red oval
green line
Magenta filled circle
red arc
ArcExample
Positioning: adjusting the x and y
advantages of awt Disadvantages of awt
✅ Simple and easy to use for ❌ UI appearance differs across
small applications. operating systems.
Uses the Applet class from java.applet and java.awt for graphical
components.
hehehehehehehehehehehehhe
applet life cycle methods
1. init() – Called once when the 5. destroy() – Called once when the
applet is first loaded; used for applet is closed or removed, used to
initialization. free up resources (e.g., closing
2. start() – Called after init() and connections).
whenever the applet is restarted 6. repaint() – A method that triggers
(e.g., when the user revisits the page). the paint() method to refresh the UI
3. paint(Graphics g) – Called (e.g., after an event like a button
whenever the applet needs to be click).
redrawn, such as after resizing or 7. update(Graphics g) – Called before
updating content. paint() to clear the screen; can be
4. stop() – Called when the applet is overridden for custom behavior.
paused, such as when the user
navigates away from the page.
advantages of applet Disadvantages of applet
✅ Runs directly in a web ❌ Deprecated in modern Java
browser (no need for (not supported in new browsers).
installation).
❌ Security restrictions limit file
✅ Platform-independent (runs access and system interaction.
on any system with Java
support). ❌ Requires Java Plugin, which is
no longer available in most
✅ Supports interactive graphics browsers.
and animations.
Event & exception
handling
What is event handling?
Handles events in
actionPerformed(ActionEvent e),
which prints "Button Clicked!" when
clicked.
hshshshshshsshh
ehheehhehe
What is exception handling?