Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Draw An Arc in Graphics 
 

An arc of a circle is a segment of the circumference of the circle. To draw an arc, class Arc2D is used.

 

Draw An Arc in Graphics

                         

In this section, you will learn how to draw an arc in Graphics.

An arc of a circle is a segment of the circumference of the circle. To draw an arc, class Arc2D is used. To give the stylistic and impressive way to the outline of arc, we have used BasicStroke class. The float value passed into the constructor of Class BasicStroke shows the thickness of the outline.

The method setPaint() paints the shape with specified color. The method setStroke() sets the stroke settings. The method frame.setSize() sets the size of frame and frame.show() shows the frame.

 

 

Here is the code of DrawAnArc.java

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.geom.*;

public class DrawAnArc extends JApplet {
  BasicStroke basicStroke = new BasicStroke(5.0f);  
    public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setPaint(Color.red);
    g2d.setStroke(basicStroke);
    g2d.draw(new Arc2D.Double(51015015060150,
        Arc2D.OPEN));
    }
  public static void main(String s[]) {
    JFrame frame = new JFrame("Draw Arc");
    JApplet applet = new DrawAnArc();
    frame.getContentPane().add("Center", applet);
    frame.setSize(300250);
    frame.show();
  }
}

Download Source Code

Download Source code

                         

» View all related tutorials
Related Tags: c com image class list object diff components stack icons user sed entity icon order component ai define container show

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

how we can run again an again with color change draw circle

Posted by ajay on Friday, 04.10.09 @ 08:44am | #86693

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.