AWT Image

Ads
 

AWT Image

I have loaded two images using toolkit in java.one is concentric rectangle and other is concentric circle.kindly someone send me the source code of interchanging the inner most rectangle with the inner most circle and inner circle with inner rectangle.

View Answers

June 28, 2011 at 5:27 PM

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

class DrawRectAndCir extends JPanel{
    public void paint( Graphics g ) {
g.drawOval (50, 10, 220, 220);
g.drawOval (70, 30, 180, 180);
g.drawOval (90, 50, 140, 140);
g.drawOval (110, 70, 100, 100);
g.drawOval (130, 90, 60, 60);
g.drawRect (150, 110, 20, 20);

g.drawRect (300, 10, 300, 220);
g.drawRect (320, 30, 260, 180);
g.drawRect (340, 50, 220, 140);
g.drawRect (360, 70, 180, 100);
g.drawRect (380, 90, 140, 60);
g.drawOval (400, 110, 100, 20);

   }
}

public class DrawConcentricRectangleAndCircles extends JPanel {

  public void paint(Graphics g) {
g.drawOval (50, 10, 220, 220);
g.drawOval (70, 30, 180, 180);
g.drawOval (90, 50, 140, 140);
g.drawOval (110, 70, 100, 100);
g.drawOval (130, 90, 60, 60);
g.drawOval (150, 110, 20, 20);

g.drawRect (300, 10, 300, 220);
g.drawRect (320, 30, 260, 180);
g.drawRect (340, 50, 220, 140);
g.drawRect (360, 70, 180, 100);
g.drawRect (380, 90, 140, 60);
g.drawRect (400, 110, 100, 20);
  }


  public static void main(String s[]) {
  final JFrame frame = new JFrame("Show Triangle");
  final JPanel p = new DrawConcentricRectangleAndCircles();
  final JPanel p1=new DrawRectAndCir();
  JButton b=new JButton("Convert");
  b.setSize(100,20);
  b.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e){
         p.setVisible(false);
         frame.getContentPane().add("Center", p1);
          p1.setVisible(true);
      }
  });
  p1.setVisible(false);
  frame.getContentPane().add("Center", p);
   frame.getContentPane().add("South", b);

  frame.setSize(650,320);
  frame.show();
  }
}

Ads









Related Tutorials/Questions & Answers:
AWT Image
AWT Image  I have loaded two images using toolkit in java.one is concentric rectangle and other is concentric circle.kindly someone send me the source code of interchanging the inner most rectangle with the inner most circle
Image Manipulation in Swing AWT
Image Manipulation in Swing AWT  Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later
Advertisements
awt
Java AWT Applet example  how to display data using JDBC in awt/applet
awt
JDBC and AWT to display data  how to display data using JDBC in awt/applet
awt
JDBC in awt applet  how to display data using JDBC in awt/applet
awt
JDBC in awt  how to display data using JDBC in awt/applet
awt in java
awt in java  using awt in java gui programming how to false the maximization property of a frame
awt jdbc
awt jdbc  programm in java to accept the details of doctor (dno,dname,salary)user & insert it into the database(use prerparedstatement class&awt
AWT Tutorials
AWT Tutorials  How can i create multiple labels using AWT????   Java Applet Example multiple labels 1)AppletExample.java: import javax.swing.*; import java.applet.*; import java.awt.*; import
java awt calender
java awt calender  java awt code for calender to include beside a textfield
image
image  how to add the image in servlet code
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
What is AWT in java
What is AWT in java In this Example we will describe awt in java. The awt in java stands for Abstract Windowing Toolkit and is a package available with JDK. awt contains all classes and develops user interface objects like
image
image   Dear every body please help me how to add and retrive image and video into oracle 11g using jsp
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException  ... is clicking I getting the error : Exception in thread "AWT-EventQueue-0... { Image m; Thread t; NextPage(final String uname
another frame by using awt or swings
another frame by using awt or swings  how to connect one frame to another frame by using awt or swings
java awt package tutorial
Java AWT Package In Java, Abstract Window Toolkit(AWT) is a platform... programming language, the AWT is also platform-independent. A common set.... The implementation of the user interface elements provided by the AWT is done using
Awt programming with java
Awt programming with java  Write a java program, which provides a text area with horizontal and vertical scrollbar.Type some lines in the text area and use scrollbars to move the text within the text area.Read a word in a text
Version of com.globalmentor>globalmentor-awt dependency
List of Version of com.globalmentor>globalmentor-awt dependency
Version of com.levigo>gwt-awt dependency
List of Version of com.levigo>gwt-awt dependency
date and time in awt(java)
date and time in awt(java)  sir, do you have an example of date in awt java which can be view over a textfield.   Display time in JTextField import java.util.*; import javax.swing.*; import java.awt.event.*; public
java swing - Swing AWT
java swing  how to add image in JPanel in Swing?  Hi Friend... DisplayImage extends JPanel{ private BufferedImage image; public DisplayImage() { try { image = ImageIO.read
Calling awt Frame methods from subclass
Calling awt Frame methods from subclass  Calling awt Frame methods from subclass
Java swings - Swing AWT
Java swings  i have the following class .In that class i has two panels,panel1and panel2.panel1 contains an image.i want drag it in panel2(gray background).but i dont want to remove the image from panel1.i want
Version of batik>batik-awt-util dependency
List of Version of batik>batik-awt-util dependency
Maven Dependency gwt-awt >> 0.0.2
You should include the dependency code given in this page to add Maven Dependency of com.levigo >> gwt-awt version0.0.2 in your project
Maven Dependency globalmentor-awt >> 0.5.0
You should include the dependency code given in this page to add Maven Dependency of com.globalmentor >> globalmentor-awt version0.5.0 in your project
Maven Dependency gwt-awt >> 0.0.1
You should include the dependency code given in this page to add Maven Dependency of com.levigo >> gwt-awt version0.0.1 in your project
Maven Dependency gwt-awt >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.levigo >> gwt-awt version1.0.0 in your project

Ads