Write a program on filling rectangles, JAVA Programming

Write a program on Filling Rectangles ?

The drawRect() method draws an open rectangle, a box if you prefer. If you need to draw a filled rectangle, use the fillRect() method. Or else the syntax is identical.
This program draws a filled square in the center of the applet. This needs you to separate the applet width and height from the rectangle width and height. Here's the code:
import java.applet.*;
import java.awt.*;

public class FillAndCenter extends Applet {

public void paint(Graphics g) {

int appletHeight = this.getSize().height;
int appletWidth = this.getSize().width;
int rectHeight = appletHeight/3;
int rectWidth = appletWidth/3;
int rectTop = (appletHeight - rectHeight)/2;
int rectLeft = (appletWidth - rectWidth)/2;

g.fillRect(rectLeft, rectTop, rectWidth-1, rectHeight-1);



Posted Date: 5/16/2013 7:30:48 AM | Location : United States

Related Discussions:- Write a program on filling rectangles, Assignment Help, Ask Question on Write a program on filling rectangles, Get Answer, Expert's Help, Write a program on filling rectangles Discussions

Write discussion on Write a program on filling rectangles
Your posts are moderated
Related Questions

Implement a program that can compute your taxes (assume year 2012, as- sume a form 1040EZ). The form should ask for your ling status (single, married), income, deductions and cred

This assignment is about experimenting with the Java runtime system's garbage collection model, and comparing it with the C++ manual memory allocation model. Below is the Garbage J

What Can an Applet Do? An applet can: • Draw pictures on a web page • Create a new window and draw in it. • Play sounds. • Receive input from the user by the keyboard or

Explain what is constructors ? It is frequent the case in which overloaded techniques are essentially the similar except that one supplies default values for a few of the argum

JavaScript supports the normal control structures: The conditionals if, if...else, & switch; The iterations for, while, do...while, break, & continue;

YES. JSP technology is extensible by the development of custom actions, or tags, which are encapsulated in tag libraries. #question..

What is 'public static void main (String args[ ] ) ' signifies? Access specifier is the 'public' keyword. 'static' keyword allows main() to called without instantiating

create and initialize the two dimensional array called table Numbers of type integer. use nested loops that will add 12 to each element in an array. use nested loops that will get