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
Program 1. Write a Java program to display the first 20 Fibonacci numbers Program with Fibonacci sequence of first 20 terms Output 2. Write an applet progr

Program of Declaration of variables in Java Program for declaring variables in Java, I've been trying so many codes for this but those codes didn't work well. Please write the

How to Returning Multiple Values From Methods ? It is not probable to return more than one value from techniques. You cannot, for example, return the licensePlate, speed and m

Name Conflicts when importing packages It is possible which you will try to import a package which contains classes in which have the similar name as a class in your own source

How to Write Exception Subclasses ? Most exception subclasses inherit all their functionality from the superclass. Each subclass majorly serves as a marker for a various types

Application or website to upload DICOM files from CD to Drop box etc Project Description: I need a website code or application to make patients put a cd or DVD to their disk

You will be required to create an ADT for a Binary Search Tree (BSTInterface.java). The interface will be implemented as a Binary Search Tree (BST) using a reference based format.

List the Parentheses used in Java language? As usual here's the output: % javac FahrToCelsius.java % java FahrToCelsius 0 -17.7778 20 -6.66667 40 4.44444 60 15.5556 80 26.6667

What is Overloading explain with an example? Overloading is while the similar method or operator can be used on several different kinds of data. For example the + sign is used

i''m trying to make a code to make the simon says game and i can''t figure it outt