Question: package graphics; import java.awt. * ; import java.awt.event. * ; public class DrawShapes extends Frame { public void paint ( Graphics g ) { /

package graphics;
import java.awt.*;
import java.awt.event.*;
public class DrawShapes extends Frame {
public void paint(Graphics g){// creates the content of the frame
Graphics2D ga =(Graphics2D) g;
ga.setPaint(Color.RED);
ga.drawOval(150,50,100,100);
ga.setColor(Color.BLUE);
ga.fillOval(175,150,100,100);
ga.setPaint(Color.GREEN);
ga.drawRect(50,200,100,100);
ga.setColor(Color.YELLOW);
ga.fillRect(175,200,100,100);
ga.setColor(Color.MAGENTA);
ga.setStroke(new BasicStroke(3));
ga.drawLine(50,350,275,350);
}
public static void main(String args[]){
DrawShapes frame = new DrawShapes(); // frame is the new object
frame.addWindowListener(new WindowAdapter(){// to receive window events
public void windowClosing(WindowEvent we){// when window is closed
System.exit(0);
}
});
frame.setSize(350,400); // sets size
frame.setVisible(true); // makes it visible
}
}

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!