Write a java code to draw ovals and circles, JAVA Programming

Assignment Help:

Write a java code to draw Ovals and Circles?

Java has techniques to draw outlined and filled ovals. As you'd probably guess these methods are called drawOval() and fillOval() correspondingly. As you might not guess they take identical arguments to drawRect() and fillRect(), i.e.

public void drawOval(int left, int top, int width, int height)
public void fillOval(int left, int top, int width, int height)

Instead of the dimensions of the oval itself, the dimensions of the smallest rectangle which can enclose the oval are specified. The oval is drawn as large as it can be to touch the rectangle's edges at their centers. This picture might help:

415_rectangle1.png

The arguments to drawOval() are the similar as the arguments to drawRect(). The first int is the left hand side of the enclosing rectangle, the second is the top of the enclosing rectangle, the third is the width and the fourth is the height.

There is no special method to draw a circle. Just draw an oval inside a square.

Java also has methods to draw outlined and filled arcs. They're similar to drawOval() and fillOval() but you must also specify a starting and ending angle for the arc. Angles are given in degrees. The signatures are:public void drawArc(int left, int top, int width, int height,
int startAngle, int stopAngle)
public void fillArc(int left, int top, int width, int height,
int startAngle, int stopAngle)
The rectangle is filled with an arc of the largest circle that could be enclosed within it. The location of 0 degrees and whether the arc is drawn clockwise or counter-clockwise are currently platform dependent.


Related Discussions:- Write a java code to draw ovals and circles

Want a page to store emails when click as save, Want a page to store emails...

Want a page to store emails when click as save, then pass along to another page with the emails in the URL Project Description: I have a page that populates with listing; the

Exception handling in EJB, Java has two kinds of exceptions: 1. Checked ...

Java has two kinds of exceptions: 1. Checked exception: handled from java.lang.Exception but not java.lang.RuntimeException. 2. Unchecked exception: handled from java.lang.Ru

What are synchronized methods and synchronized statements, What are synchro...

What are synchronized methods and synchronized statements? Synchronized methods are methods that are used to control access to an object. A thread only implements a synchronize

Zhtml requirements, In addition to your Java code requirements, you also ne...

In addition to your Java code requirements, you also need to enhance the ZHTML for your application. As before, you can continue working with the page(s) you used for the previous

What is externalizable interface, What is Externalizable interface? Ext...

What is Externalizable interface? Externalizable is an interface which have two methods readExternal and writeExternal. These methods give you a control over the serialization

Game of life, Conway's Game of Life is a "cellular automaton" that is playe...

Conway's Game of Life is a "cellular automaton" that is played on a 2D grid (array) of cells. At the start of the game, an initial configuration is set up in which a number of cell

Explain the char data type in java, Explain the char data type in java? ...

Explain the char data type in java? A char is a single character in which a letter, a digit, a punctuation mark, a tab, a space or something same. A char literal is a single on

Application for android studio, 1- I need application used android studio w...

1- I need application used android studio with source code and all file . same this application : 2-">https://play.google.com/store/apps/details?id=com.magnetic.openmaps&hl=en 2

What is object oriented programming explain with an example, What is Object...

What is Object Oriented Programming explain with an example? In Java everything is an object or a class (or a piece of one or a collection of various). Objects send messages t

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd