-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawCircle.java
More file actions
33 lines (23 loc) · 1.09 KB
/
DrawCircle.java
File metadata and controls
33 lines (23 loc) · 1.09 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
import javax.swing.*;
import java.awt.*;
public class DrawCircle extends JLabel{ //creating the object class which extends JLabel{
private int x=15; // leftmost pixel in circle has this x-coordinate
private int y=15; // topmost pixel in circle has this y-coordinate
Color circleColor = Color.white;
public DrawCircle() { //this is the constructor
setSize(150,150);
setLocation(50,50); //setting the size, location
setVisible(true);
}
public Color getColor(){
return circleColor;
}
public void setColor(Color Scircle){ //takes in a variable of type Color, and stores it into circle
circleColor = Scircle;
}
// paint is called automatically when program begins
public void paint(Graphics g) { //using Graphics java library
g.setColor(circleColor); //setting the color based on the setter method above
g.fillOval(x,y,60,60);//change the last two numbers (60, 60) to a smaller value for better results on smaller laptops; //painting the circle
}
}