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

Write a program that takes as input a sequence of transactions of the form "buy x; share(s) at $y each" or "sell x share(s) at $y each," assuming that the transactions occur on con

Project Description: I want to build a camera application for android. By default android will add metadata for the image, for e.g.  Date, time, resolution, gps tag etc..In this

iam trying to build an application that store information like name mobile age in a file its like a registration form everytime i enter a new person data i want the applicaion mak

• Study and enhance the File System Simulator - See the FS_sim slide deck • New features - blockinfo - a new application that displays the information about the blocks in the file

Hi, For my network and security class. I have a project where I need to create a program that take an input and encrypts it and then you can also enter that value into another tex

Describe about User Security Issues and Social Engineering ? Contrary to popular belief most computer break-ins through external hackers don't happen since of great knowledge

Use of WebLogic Platform in Project: Technologies Tools: Weblogic 8.1, Solaris 9, MQ Series 6.0, iplanet 6.1, Mercury Test Director. Project Overview: Wellington Manag

A question rising in the mind of XML/DTD designers is whether to model and encode retain information using an attribute, or alternatively, using an element. 1. Using  an  elemen