Code To Draw A Circle in Java Programming
Here’s a Java Graphics Code To Draw A Circle in Java Programming using Swing and AWT. This Java Graphics Program makes a Circle with Color Filled inside it.
This Java Program To Draw A Circle includes the following Import Files:
A Frame in a Java Program is implemented as an instance of the JFrame Class. Java Applications that require Graphical User Interface (GUI) feature makes use of JFrame. JFrame is a Dialog Box or a Window that provides decorations such as:
- Button Components
These Button Components helps to Close the Windows Box and also helps to Iconify the Window.
The Important Methods in this Program are:
- drawOval(): This method is used to draw the Shape of the Circle / Oval.
- setColor(): This methods helps to set the Color to be filled inside the Circle / Oval.
- fillOval(): This method fills the Color within the Oval shape.
Code To Draw A Circle in Java Programming Language
public class Circle extends JFrame
public void paint(Graphics g)
g.fillOval(480, 480, 200, 200);
public static void main(String args)
Circle t = new Circle();
You can therefore draw different Shapes in Java by using proper built-in methods and by setting the Dimensions of the Shape to a proper format.
If you have any Compilation Errors or Doubts about this Code To Draw A Circle in Java Programming, Comment Section is awaiting you.