-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFill_Color_Applet.java
More file actions
40 lines (33 loc) · 1.27 KB
/
Fill_Color_Applet.java
File metadata and controls
40 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* Program: Fill Color Applet
* Description: A basic Java Applet to demonstrate graphics drawing and color filling.
* It draws a rectangle and fills it with yellow color.
* Author: Amey Thakur
* Reference: https://github.com/Amey-Thakur/OOPM-JAVA-LAB
*
* Note: Applets are deprecated in newer Java versions. This is for educational purposes.
* To run: Use 'appletviewer Fill_Color_Applet.html' or an IDE that supports Applets.
*/
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class Fill_Color_Applet extends Applet {
/**
* Paint method to draw graphics on the applet window.
* @param g The Graphics object used for drawing.
*/
@Override
public void paint(Graphics g) {
// Drawing a rectangle outline
// x=30, y=50, width=200, height=100 (Adjusted coordinates to be visible in standard window)
g.drawRect(30, 50, 200, 100);
// Setting color to yellow for filling
g.setColor(Color.YELLOW);
// Filling the rectangle
g.fillRect(30, 50, 200, 100);
// Setting color to magenta for text
g.setColor(Color.MAGENTA);
// Drawing text description
g.drawString("Rectangle Filled with Yellow", 30, 170);
}
}