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
What is the purpose to use the enableEvents() method?

write a program to find the area under the curve y=f(x) between x=a and x=b,integrate y=f(x) between the limits of a and b.   #include float start_point,

What is difference between time slicing and preemptive scheduling? Differences between preemptive and time scheduling are: In case of Preemptive scheduling the highest prior

how to write bank system

Change encrypted HSQL database into CSV format Project Description: We have an encrypted HSQL Database which we have to convert into csv format. HSQL DB . We have java app

Application Rewrite Project Description: There is an app that I want to be rewritten in order to support multiple profiles. The App is an OTP generator. It is required to

Struts Framework gives the functionality to validate the form data. It can be use to authenticate the data on the users browser as well as on the server side. Struts Framework emit

Task I have an Android mobile app project that I''m trying to get profiles to transfer by connecting to a server at port 1337. I have to send a json string to the se

Implement the Money class discussed in class. This class should represent a dollar and cents amount with 0-99 cents and the cents being the same sign as the dollars. The class shou

Explain what is Object in JAVA language? They are foundation of object oriented language. They are data structure holds data fields and properties and methods