banner



How To Draw A Simple Circle In Java

How to Create Circle In Coffee

This is a simple plan of java awt. In this section, you will acquire how to create Circle Diagram. The coffee circle is the near fundamental abstractions in a Java 2nd in the supported java.awt.shape parcel. It describes a shape. But the Java 2D definitio

This is a unproblematic program of java awt. In this section, you will learn how to create Circle Diagram. The java circumvolve is the most fundamental abstractions in a Java 2nd in the supported coffee.awt.shape package. It describes a shape. But the Java 2d definitio

How to Create Circle In Java

Introduction:

This is a unproblematic plan of java awt. In this section, you volition learn how to create Circumvolve Diagram. The coffee circle is the most primal abstractions in a Coffee 2D in the supported java.awt.shape parcel. Information technology describes a shape. Simply the Coffee 2d definition of a shape does not require the shape to enclose an area. The Java2D API  also provides several classes that defines common Geometric Objects.

Plan Description:

In this program, y'all will also show that how to create square drawing. Inside the programme ascertain a class name CircleDraw for the circumvolve component.  There is created two types of diagrams "Circle" and "foursquare" for this program. Here, this plan uses Ecllpise2D that is implemented to specify eclipse bladder and double. double and float components are represented for creating the square and circle in this program.

setPaint(): This class is used for filling the colour.

Here is the code of this program:

import java.awt.*;
import java.awt.event.*;
import coffee.awt.geom.*;

public class CircleDraw extends Frame {
Shape circumvolve = new Ellipse2D.Bladder ( 100.0f , 100.0f , 100.0f , 100.0f ) ;
Shape square = new Rectangle2D.Double ( 100 , 100 , 100 , 100 ) ;
public void paint ( Graphics g ) {
Graphics2D ga = ( Graphics2D ) g;
ga.depict ( circle ) ;
ga.setPaint ( Color.green ) ;
ga.make full ( circle ) ;
ga.setPaint ( Color.red ) ;
ga.draw ( square ) ;
}

public static void principal ( Cord args []) {
Frame frame = new CircleDraw () ;
frame.addWindowListener ( new WindowAdapter (){
public void windowClosing ( WindowEvent we ){
Organization.exit ( 0 ) ;
}
}) ;
frame.setSize ( 300 , 250 ) ;
frame.setVisible ( true ) ;
}
}

Output this plan:

Download this plan.

Ads

Source: https://www.roseindia.net/java/example/java/awt/how-to-create-circle-in-java.shtml

Posted by: greentheopect.blogspot.com

0 Response to "How To Draw A Simple Circle In Java"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel