Complete the following code to display an applet, so that the contents are contained in a rectangle around the phrase "Exercise Applet". Use starting coordinates 5, 15 for the string. public void paint(Graphics g) { //Draw a Rectangle around the applet's display area. //Draw the current string inside the rectangle. }

Respuesta :

Answer:

//. Program is written in Java Programming Language

// Comments are used for explanatory purpose

// Program starts here

// import required libraries

import java.swing.JApplet;

import java.awt.*;

// Declare class as

public class DrawGraphics extends JApplet

{

//.Assume the following values for width, height and area of the shape

final int area= 150 ;

final int width = 100, height = 50;

{

//Draw a Rectangle around the applet's display area starting from 5,15

g.drawRect( 5,15, area-1, area-1 );

//Draw the current string inside the rectangle

g.drawRect( area/2 - width/2 , area/2 - height/2, width, height );

}

}