Question: import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; import javax.swing.JFrame; import javax.swing.JPanel; public class myPane1 extends JPanel { /* * sample

import java.awt.Color;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.geom.Ellipse2D;

import java.awt.geom.Rectangle2D;

import java.awt.geom.RoundRectangle2D;

import javax.swing.JFrame;

import javax.swing.JPanel;

public class myPane1 extends JPanel {

/* * sample question for 2d graphics */

private static final long serialVersionUID = 8120526119594813134L;

public static final int Small= 50;

public static final int Medium = 100;

public static final int Large = 150;

public myPane1() {

setBackground(Color.WHITE);

}

public void paintComponent(final Graphics theGraphics) {

super.paintComponent(theGraphics);

final Graphics2D g2d = (Graphics2D) theGraphics;

g2d.setPaint(Color.BLACK);

// g2d.draw(new Rectangle2D.Double(150, 150, 700, 700));

// for (int i = 0; i < 10; i +=2) {

// if (i % 3 == 0) {

// g2d.fill(new Ellipse2D.Double(i*100, i*100, 100, 100));

//

// } else {

// g2d.draw(new Ellipse2D.Double(i*100, i*100, 100, 100));

//

// }

// }

//g2d.draw(new RoundRectangle2D.Double(Large+100, Small, Medium, Medium, Small, Small));

g2d.draw(new Ellipse2D.Double(Small, 0,Large, Large));

g2d.fill(new Rectangle2D.Double(0, Medium , Small,Small));

g2d.draw(new Rectangle2D.Double(Small+Large, 0, Small, Small+3));

g2d.draw(new Rectangle2D.Double(0, 0, Small, Medium));

g2d.fill(new Ellipse2D.Double(Small+2, Medium,Large/3, Large/3));

//g2d.fill(new Ellipse2D.Double(Large, Large,Large, Large));

}

public static void main(String[] args) {

final myPane1 panel = new myPane1 ();

final JFrame frame = new JFrame(" Demo");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.add(panel);

frame.setLocationRelativeTo(null);;

frame.pack();

frame.setVisible(true);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!