您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)

 

Content Index

Content Page # 12

Example of filled rectangle primitive

Consider the rectangle displayed by this applet:

The code for this applet is as follows:

import java.applet.Applet;

import java.awt.*;

public class FillRect1 extends Applet
{

  public void paint( Graphics g )
  {
    int xPos = 50;
    int yPos = 50;
    int w = 100; // width
    int h = 20; // height
    g.setColor( Color.red );
    g.fillRect( xPos, yPos, w, h);
  }
 } // class

As can be seen a fillRect() message was sent to the Graphics object g.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg