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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Draw Dashed Oval 
 

To give the stylistic and impressive representation of the outline, we have used the class BasicStroke.

 

Draw Dashed Oval

                         

This section illustrates you how to draw a dashed oval.

To give the stylistic and impressive representation of the outline, we have used the class BasicStroke. This class has been given by the interface Stroke. The class BasicStroke defines some methods to give the impressive way of showing the outline. 

The BasicStroke.CAP_BUTT gives the dash segments. The BasicStroke.JOIN_BEVEL connects the outer corners of outlines with a straight segment. The class Ellipse2D is defined to provide the round figure which shows the outline.

The method setPaint(Color.gray) paints the outline with gray color. The method setStroke() sets the stroke settings for the Graphics2D context, when you draw the shape.

Here is the code of DrawDashedOval.java

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

public class DrawDashedOval extends JApplet {
  public void init() {
    setBackground(Color.white);
   }
   float fl[] = { 12.0f };
   BasicStroke basicStroke = new BasicStroke(2.0f,
   BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 12.0f,
      fl, 
0.0f);
  
   public void paint(Graphics g) {
    Graphics2D g2d = (Graphics2D) g;
    g2d.setPaint(Color.gray);
    g2d.setStroke(basicStroke);
    g2d.draw(new Ellipse2D.Double(5050250250));
   }
   public static void main(String args[]) {
    JFrame frame = new JFrame("Show Dashed Oval");
    DrawDashedOval dashedOval= new  DrawDashedOval();
    frame.getContentPane().add("Center", dashedOval);
    dashedOval.init();
  frame.setSize(350350);
    frame.setVisible(true);
  }
}

Output will be displayed as:

Download Source Code

                         

» View all related tutorials
Related Tags: c memory image class images interface io colors sed color get implementation display icon height value source width int id

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 
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.