Switch to full style
General Java code examples
Post a reply

Draw Dashed Oval in java

Tue Nov 11, 2008 6:16 pm

Draw Dashed Oval in java
Code:
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(50, 50, 250, 250));
   }
   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(350, 350);
    frame.setVisible(true);
  }
}



Attachments
dashedOval.gif
draw dashed oval output
dashedOval.gif (6.05 KiB) Viewed 5554 times

Post a reply
  Related Posts  to : Draw Dashed Oval in java
 draw Oval in java     -  
 Draw Oval,Arc,Polygon,string,Line,Round and 3D Rectangle     -  
 Add dashed border to text div     -  
 Draw An Arc in java     -  
 draw Calendar in java     -  
 Draw Flag in Java     -  
 draw text effects in java     -  
 Changing the color of a graph draw in java     -  
 Java code to draw shortest path tree     -  
 draw cube 3d java-Cube 3D     -  

Topic Tags

Java Graphics