Tue Nov 11, 2008 8:47 pm
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 = (Graphics2D) g;
g2.setPaint(Color.red);
int x = 6;
int y = 8;
g2.setStroke(stroke);
g2.draw(new Rectangle2D.Double(x, y, 150, 150));
g2.draw(new Ellipse2D.Double(x, y, 150, 150));
}
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(250, 200);
frame.show();
}
}
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
Powered by phpBB © phpBB Group.