Monday, 26 January 2015

How To Draw A Rectangles In Applet


The drawRect() and fillRect() methods display an outlined and filled rectangle respectively.They shown below.
void drawRect(int top,int left,int width,int height)
void fillRect(int top,int left,int width,int height)
The upper-left corner of the rectangle is at top left.The dimensions of the rectangle are specified by width and height.

ROUND RECTANGLES:

To draw a rounded rectangle,use drawRondRect() or fillRoundRect(),both shown below
void drawRoundRect(int top,int left,int width,int height,int xDiam,int yDiam)
void fillRoundRect(int top,int left,int width,int height,int xDiam,int yDiam)

A round rectangle has rounded corners.The upper left-corner is at top-left.The dimension is specified as same as rectangle additionally it also has arc along x and y axis specified by xDiam,yDiam.

HTML CODING:

<html>
<body>
<applet code="recapp" width="300" height="300">
</applet>
</body>
</html>

JAVA CODING:

import java.applet.*;
import java.awt.*;
public class recapp extends Applet
{

public void paint(Graphics g){
g.drawRect(10,10,60,50);
g.fillRect(100,10,60,50);
g.drawRoundRect(190,10,60,50,15,15);
g.fillRoundRect(70,90,140,100,30,40);
}

}



No comments:

Post a Comment