Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Rectangle Image in Java

                         

Introduction

In this section, you will learn how to create rectangle image. This program used the Graphics2D class which extends the Graphic class and control  all geometry or coordinate transformation and color management, text layout. The Java programming in  java 2D API provides several classes. It defines that common  geometry object such as lining drawing , rectangle Drawing , curve drawing and Circle. All types of Geometry classes parts are  supported by java.awt.geom package.

Program Description:

In this program, you can also see how to used Rectangle2D for rectangle component. Define, first of all, class name for the rectangle component. The rectangle2D class describes a rectangle and is defined by the this location (x , y) coordinate and dimension (width , height).

Rectangle2D.Double(): This class is used to define a rectangle specified in double coordinate.  

setPaint(): This component used for filling the color into the rectangle image.

Here is the code of this program:

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class AWTRectangle extends Frame {
  Stroke drawingStroke = new BasicStroke(3);
  Rectangle2D rect = new Rectangle2D.Double(607012080);
  
  public void paint(Graphics g) {
    Graphics2D g1 = (Graphics2D)g;
    g1.setStroke(drawingStroke);
    g1.draw(rect);
    g1.setPaint(Color.yellow);
    g1.fill(rect);
    }
  public static void main(String args[]) {
    Frame frame = new AWTRectangle();
    frame.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent we){
        System.exit(0);
      }
    });
    frame.setSize(300200);
    frame.setVisible(true);
  }
}

Output this program:

Download this program.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
java.nio
jsp to microsoft sql
optgroup
where we place ...-in
collection classes
a sample example forh
rmi
parseInt
spring application
Sample paging program
Flex TreeGrid
Tiles definition richf
download package com.s
button launches dialog
sleep
getRequestDispatcher s
how to override...ng i
ibatis fundamental
Hibernate Mapping
jQuery To Slide Effect
Nested WHILE LOOPS
pos
source code for change
)How
textfield password
Delete database
java random numbers
checkbox struts 1
FILEUPLOADEXAMPLEWITHD
day number given date
update all columns of
create xml using java
J2EE interview questio
PHP User Authenticatio
jdbc connections
executequery
Combattons la programm
remove rectangle
string variable
Merge Sort In Java
Flash Math Physics Fla
Photoshop Effects Crea
HQL
Photoshop Basics Kodak
lazy load in hibernate
increase size of strut
logout code in jsp
calculator code usind
java strings
what is static inner c
using set in java
EncoderTest
password match jsf
Copy One Database Tabl
checkbox button enable
simple calendar
ajax
embedded java script i
how to use tab control
HSSF clone cell
Arraylist text file
What are the defined J
jsp applet netbeans
linked list
SwingWorker
launch dialog with but
charts using POI
save image
Static Fields
spring hibernate web e
how to override a vari
storing text data to a
tibco
finding superscript in
xls
getNumericValue
Cloneable
Photoshop Text Effects
Binome
Photoshop Photo Effect
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.