Total members 11890 |It is currently Sat Apr 20, 2024 2:01 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





drawing Ellipse in Rectangle using java graphics
Code:
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;

public class 
DrawRectangleAndEllipse extends JApplet {
  final static 
BasicStroke stroke = new BasicStroke(2.0f);
  public 
void init() {
    
setBackground(Color.white);
    
setForeground(Color.white);
  }
  public 
void paint(Graphics g) {
    
Graphics2D g2 = (Graphics2Dg;
    
g2.setPaint(Color.red);
    
int x 6;
    
int y 8;
    
g2.setStroke(stroke);
    
g2.draw(new Rectangle2D.Double(xy150150));
  
g2.draw(new Ellipse2D.Double(xy150150));
    }
  public static 
void main(String args[]) {
    
JFrame frame = new JFrame("Draw Ellipse inside Rectangle");
    
JApplet applet = new DrawRectangleAndEllipse();
    
frame.getContentPane().add("Center"applet);
    
applet.init();
    
frame.setSize(250200);
    
frame.show();
  }





Attachments:
File comment: drawing Ellipse in Rectangle
rectEll.gif
rectEll.gif [ 4.58 KiB | Viewed 6654 times ]

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada
Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Ellipse in Rectangle
 ellipse, circle, rectangle, square, or parallelogram     -  
 Draw Filled Ellipse in php     -  
 Java Rectangle Class     -  
 How to Calculate Volume of a Rectangle     -  
 Draw rectangle on image     -  
 Draw Fill Rectangle     -  
 Drawing rectangle using stars in java     -  
 Draw Oval,Arc,Polygon,string,Line,Round and 3D Rectangle     -  



Topic Tags

Java Graphics






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com