Question: Using the code: import java.applet.*; import java.awt.*; public class DrawingStuff extends Applet { int width, height; public void init() { width = getSize().width; height =

Using the code:

import java.applet.*;

import java.awt.*;

public class DrawingStuff extends Applet {

int width, height;

public void init() {

width = getSize().width;

height = getSize().height;

setBackground( Color.black );

}

public void paint( Graphics g ) {

// As we learned in the last lesson,

// the origin (0,0) is at the upper left corner.

// x increases to the right, and y increases downward.

//red rectangle

g.setColor( Color.red );

g.drawRect( 10, 20, 100, 15 );

g.setColor( Color.pink );

g.fillRect( 240, 160, 40, 110 );

//oval

g.setColor( Color.blue );

g.drawOval( 50, 225, 100, 50 );

g.setColor( Color.orange );

g.fillOval( 225, 37, 50, 25 );

//arc

g.setColor( Color.yellow );

g.drawArc( 10, 110, 80, 80, 90, 180 );

g.setColor( Color.cyan );

g.fillArc( 140, 40, 120, 120, 90, 45 );

//arc

g.setColor( Color.magenta );

g.fillArc( 150, 150, 100, 100, 90, 90 );

g.setColor( Color.black );

g.fillArc( 160, 160, 80, 80, 90, 90 );

//string

g.setColor( Color.green );

g.drawString( "Groovy!", 50, 150 );

}

}

Show a square, cricle and triangle in one frame.

Then make the square blue, circle purple and triangle red.

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!