Something trivial but I can't work it out :/

Okay basically, I want my buttonOval to draw an oval for me. Here is my code:
import java.awt.*;                                                  //Import all the classes within the abstract windows toolkit
import java.applet.*;                                                  /Import applet class
import java.awt.event.*;
import java.awt.Graphics.*;
public class Shapes extends Applet implements ActionListener
     Button buttonOval, buttonRectangle;                              //Declaration of button variables
     Font fontVerdana;                                        //Declare fonts
     TextField textx, texty, textwidth, textheight, areatext;          //Declare text fields
     Label labelx, labely, labelh, labelw;                              //Declare label fields
     int x;                                                       //Declare variable x asinteger v
     int y;
     int height;
     int width;
     int area;
     double pi = 3.14;
     public void init()
          setSize(800,500);                                                       //Size of the applet viewer
          setBackground(Color.yellow);
          fontVerdana = new Font("Verdana", Font.BOLD,10);                //Set the font
          labelx = new Label("Enter in the x co-ordinate here:");          //Declares a new label
          labelx.setBackground(Color.yellow);                                   //Background colour becomes yellow
          labelx.setFont(fontVerdana);                                        //Label prompt uses the Verdana font
          add(labelx);                                                            //Add prompt to the applet
          textx = new TextField(1);                                             //Declares a textfield for input
          add(textx);                                                                 //Adds the textfield to the applet
          textx.setForeground(Color.white);                                   //Textfield font becomes white
          textx.setBackground(Color.black);                                   //Textfield background colour becomes black
          textx.addActionListener(this);
          labely = new Label("Enter in the y co-ordinate here:");
          labely.setBackground(Color.yellow);
          labely.setFont(fontVerdana);
          add(labely);
          texty = new TextField(1);
          add(texty);
          texty.setForeground(Color.white);
          texty.setBackground(Color.black);
          texty.addActionListener(this);
          labelw = new Label("Enter in the width here:");
          labelw.setBackground(Color.yellow);
          labelw.setFont(fontVerdana);
          add(labelw);
          textwidth = new TextField(1);
          add(textwidth);
          textwidth.setForeground(Color.white);
          textwidth.setBackground(Color.black);
          textwidth.addActionListener(this);
          labelh = new Label("Enter in height here:");
          labelh.setBackground(Color.yellow);
          labelh.setFont(fontVerdana);
          add(labelh);
          textheight = new TextField(1);
          add(textheight);
          textheight.setForeground(Color.white);
          textheight.setBackground(Color.black);
          textheight.addActionListener(this);
          areatext = new TextField(20);
          areatext.setEditable(false);
          add(areatext);
          areatext.addActionListener(this);
          buttonOval = new Button("Draw Oval");
          buttonOval.setForeground(Color.white);
          buttonOval.setBackground(Color.black);
          add(buttonOval);
          buttonRectangle = new Button("Draw Rectangle");
          buttonRectangle.setForeground(Color.white);
          buttonRectangle.setBackground(Color.black);
          add(buttonRectangle);
          buttonOval.addActionListener(this);
          buttonRectangle.addActionListener(this);
     public void paint(Graphics g)
          g.drawOval(x, y, width, height);
          g.drawRect(x, y, width, height);
     public void actionPerformed(ActionEvent ev)
          if (ev.getSource() == buttonRectangle)
               x = Integer.parseInt(textx.getText());
               y = Integer.parseInt(texty.getText());
               width = Integer.parseInt(textwidth.getText());
               height = Integer.parseInt(textheight.getText());
               area = width * height;
               areatext.setText("The area is = " + area + "cm�");
               areatext.setEditable(false);
          else if (ev.getSource() == buttonOval)
               x = Integer.parseInt(textx.getText());
               y = Integer.parseInt(texty.getText());
               width = Integer.parseInt(textwidth.getText());
               height = Integer.parseInt(textheight.getText());
               area = width * height;
               areatext.setText("The area is = " + area + "cm�");
               areatext.setEditable(false);
I've used the paint method to set out the oval attributes 'g.drawOval(x, y, width, height' and I've declared all the integers and got the integer results from the textfields in which the integers are entered 'x = Integer.parseInt(textx.getText());'
but when I click the buttonOval I want it to draw the oval which is defined in the paint method. Any ideas how I can do this? As plus, it would be great if someone could tell me how to implement the area of an oval too. :D
I do apologise if this sort of thread has been posted before! Thank you for any help I appreciate. :)
Have a good day,
Jay

I've ried to compile the following but no luck...
Boolean ovalYes, rectYes;
then in the paint method...
public void paint(Graphics graf)
          if buttonOval = ovalYes
               graf.drawOval(x,y,width,height);
          else if buttonRectangle = ovalYes
               graf.drawRect(x,y,width,height);
then in the actionPerformed method...
public void actionPerformed(ActionEvent ev)
          if (ev.getSource() == buttonRectangle)
               x = Integer.parseInt(textx.getText());
               y = Integer.parseInt(texty.getText());
               width = Integer.parseInt(textwidth.getText());
               height = Integer.parseInt(textheight.getText());
               repaint(rectYes);
               area = width * height;
               areatext.setText("The area is = " + area + "cm�");
               areatext.setEditable(false);
          else if (ev.getSource() == buttonOval)
               x = Integer.parseInt(textx.getText());
               y = Integer.parseInt(texty.getText());
               width = Integer.parseInt(textwidth.getText());
               height = Integer.parseInt(textheight.getText());
               repaint(ovalYes);
               area = width * height;
               areatext.setText("The area is = " + area + "cm�");
               areatext.setEditable(false);
It doesn't work. :s

Similar Messages

  • I have Pages 09 and I have  created a business card using the template but can't figure out how to duplicate it to the other 9 on the page Am and sure I am going to look daft coz its only the click of a button but I can't work it out Thanks

    I have Pages 09 and I have  created a business card using the template but can't figure out how to duplicate it to the other 9 spaces on the page. I am and sure I am going to look daft coz its only the click of a button but I can't work it out Thanks

    I do the following: Hold down the command key and highlight all the items to be reproduced. Then hold down option and drag the items from the first to each subsequent card.

  • I have paid for Creative Cloud - illustrator CC 1 year monthly plan, but it still show "Trial Expired". I have tried to sign in and sign out creative cloud many times, but still can't work. Please help!

    I have paid for Creative Cloud - illustrator CC 1 year monthly plan, but it still show "Trial Expired". I have tried to sign in and sign out creative cloud many times, but still can't work. Please help!

    Does your Cloud subscription show on your account page?
    https://www.adobe.com/account.html for subscriptions on your Adobe page
    Also,
    This is an open forum, not Adobe support... you need Adobe support to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"

  • I prepare chronologies in word, and i am trying to do the same in pages using tables and cells. But somtimes i need a cell to wrap onto the next page but I can't work out how to do it - any suggestions would be greatly appreciated

    I prepare chronologies in word, and I am trying to do the same in pages using tables and cells. But sometimes I need a cell to wrap onto the next page because the contents are bigger than the page or the space left on the page,  but I can't work out how to do it - any suggestions would be greatly appreciated

    brendanfromsydney wrote:
    What are the different opinions on why pages should not achieve this?
    As far as I know, Apple is free to choose to offer this or that feature.
    They never said that they want to clone Word or even compete with it.
    Differences between tables in both worlds are numerous.
    In Pages (or Numbers)
    - we can't sort a single column
    - we can't sort by row
    - we can't insert or remove a single cell
    - a cell can't cross pages boundaries
    If I understand well these design choices match :
    ++-+-+-+-+-+-+-+-++
    Apple Human Interface Guidelines:
    Apply the 80 Percent Solution
    During the design process, if you discover problems with your product design, you might consider applying the 80 percent solution‚ that is, designing your software to meet the needs of at least 80 percent of your users. This type of design typically favors simpler, more elegant approaches to problems.
    If you try to design for the 20 percent of your target audience who are power users, your design may not be usable by the other 80 percent of users. Even though that smaller group of power users is likely to have good ideas for features, the majority of your user base may not think in the same way. Involving a broad range of users in your design process can help you find the 80 percent solution.
    +-+-+-+-+-+-+-+-+-++
    Yvan KOENIG (VALLAURIS, France) jeudi 9 juin 2011 16:03:52
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • I want to install my Quadro FX 560 to my MAC PRO, but it can't work normall

    I installed my Quadro FX 560 to my MAC PRO, but it can't work normally.
    I can't find any drivers of Quadro FX 560 for MAC OS, and I am using MAC OS 10.4.7.
    Would you like to give me the Quadro FX 560 driver for MAC OS??
    My display card come from my old PC...but not use any more...
    So I want to replace GeForce 7300 to Quadro FX560..
    Mac Pro   Mac OS X (10.4.7)  

    Would you like to give me the Quadro FX 560 driver for MAC OS??
    You will need to firstly check whether it is compatible with your Mac and operating system, and then get the required software from the manufacturers of the Quadro.

  • My ipad 2 freeze up and i've tried to reboot it, but it  can't works. and the screen is black look alike reboot.how to fix it?, my ipad 2 freeze up and i've tried to reboot it, but it  can't works. and the screen is black look alike reboot.how to fix it?

    my ipad 2 freeze up and i've tried to reboot it, but it  can't works. and the screen is black look alike reboot.how to fix it?, my ipad 2 freeze up and i've tried to reboot it, but it  can't works. and the screen is black look alike reboot.how to fix it?

    Have you tried a reset ? Press and hold both the sleep and home buttons for about 10 to 15 seconds, after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • TS1363 My iphone 4 Suddenly black out, I can't connect to itunes, I tested hold my Power and Home Button. But still can't work. My version is the lastest verion. Please help!

    My iphone 4, suddenly black out. I can't even connect to itunes, can't even turn it on. I have tried to Hold the home button and power button with 10 sec. but still can't work. Is that possible version problem? help please!

    Help what? You broke it... Make an appointment at the genius bar of your local Apple Store. A replacement phone will cost you $149.

  • I have a macbook air and I can't cut and paste in itunes.  The right clic does not work. How can I work this out?

    I have a macbook air and I can't cut and paste in itunes.  The right clic does not work. How can I work this out?

    Great tip Stephen!!
    I was so frustated from this issue that I used to use Windows iTunes for mass editing info, adding Lyrics etc and then transfering songs to Mac. This tip has alleviated my pain!!
    Thanks for the tip. This question should be tagged as answered.

  • In version 10.1 fcpx how do I edit in proxy, then when I am finished share with optimize footage? It was easy in 10.9 version, but I can't figure this out in 10.1, please help.

    in version 10.1 fcpx how do I edit in proxy, then when I am finished share with optimize footage? It was easy in 10.9 version, but I can't figure this out in 10.1, please help.

    The switch is in the upper right of the viewer.

  • HT1277 I can recieve emails but I can't send them out.  The blue bar at the bottom left of the Mail page gets half way across and then the pop-up "Cannot send message using the server" comes up?  What do I do?

    I have my Yahoo Mail "poped" over to Apple Mail.  I can recieve emails but I can't send them out.  The blue bar at the bottom left of the Mail page gets half way across and then the pop-up "Cannot send message using the server" comes up?  What do I do?

    Your outgoing mail server is different than your incoming server. Usually the outgoing mail server will have smtp in it. I noticed yours said "cannot send message using the server mail.wavecable.com". That sounds like an incoming mail server. Try setting your outgoing mail server to smtp.wavecable.com
    I hope that helps.

  • I transfer all my data iMac to my new iMac. Creative cloud is damaged. Download a new installateur but it can't work

    Hello
    I transfer all my data iMac to my new iMac. Creative cloud is damaged. Download a new installateur but it can't work

    Transferring applications between machines will not work.  You need to install using installations files.  Uninstall and Try using the CS Cleaner Tool before installing.
    Adobe Creative Suite Cleaner Tool
    helps resolve installation problems for CS3 thru CS6 and for Creative Cloud
    http://www.adobe.com/support/contact/cscleanertool.html

  • I can't use my password manager with firefox 5.0 and I want to go back to a previous verions but I can't work out how to do that

    Roboform doesn't work with firefox 5.0, but it worked with my previous version of firefox. Moreover my internet banking site does not recognise firefox 5.0 either. I want to go back to the version I had (version 3.x.x I think), but I can't see how to do it.

    @the-edmeister got me on the right track. I did have the working version of evernote, BUT I had to find the shortcut elephant button by choosing to customize the toolbar. It was at the bottom of that scroll down list. A bit tricky... And I really do need the little elephant!
    Unfortunately the Evernote site has left up information inferring that they aren't compatible with Firefox 5.
    All is good, except for my loss of work time.
    Thanks.

  • I'm having trouble importing my songs from my laptop to my iPhone, and the thing is i don't know whether the iTunes on my iPhone is broken or the one in my laptop is error. I've tried every possible way, but i can't figure it out.

    i really need help in this one because it's been like two or three months since i last imported my songs. i think the first cause to this problem was because i imported my song but i think my phone at that time didn't have enough storage or enough space for any other file. so some of the songs were imported completely, but the others weren't. so i thought it was normal bc ive been through this once, but then the next time i tried again, it still didn't worked so i deleted the none-completed imported songs and tried over three times but it didn't work, yet again. so i left it like that for about a few weeks and i tried again but it didn't worked as well. i started to browse some solution to this and i've tried to delete the songs that weren't completed and transfer the songs (which didn't work), and a few others but then i think i miss clicked a button that automatically imports all the songs in my laptop that wasn't on my phone and suddenly a few of my songs from my iphone was labeled not completely imported. i tried syncing but it got stuck on the third step which was "configuring purchased songs" and i tried updating to the new version recently but it hadn't worked too, and i wanted to try to rebuild my itunes but i didnt have the guts to do it. my total play counts has gone mad because the songs that i listen to the most, the 'plays' went from 30 to 20000+, it was just random numbers. i couldn't sync my iphone and so my photos went from 1000 to 2000, my songs were supposed to be 1200+ but its stuck on 700, my videos were supposed to be 6 but it went up to 10.
    i know the description may be a little bit too confusing but please try  to understand it because i can't solve this problem.

    carolinechx wrote:
    i know the description may be a little bit too confusing
    Mostly because you are not using any capital letters or paragraph returns and your post is difficult to read.

  • New iPad - love it - but how do I work this out

    I bought my iPad today and I love it! But here is the question: I got it in the authorized store here in Beijing, and the guy in there installed many apps for me, including the iBooks with a tone of books. Apparently, he did it from the shop's American account. Now, I would like to keep all the apps, but use my own iTunes account for downloading some more apps and for syncing the music. Is there any way to do so without losing all the apps that he installed for me? If I lose everything that has been installed, I will not be able to get most of the apps (starting with the iBooks) which have not been released in the Chinese apps store.
    Thanks a lot for any suggestion!

    Thanks for all your replies. First, let me say that I would never buy anything fake, or illegally sold anywhere in the world. But, the iPad is sold in all computer shops with Apple's license in Beijing, and it has been imported from US - not smuggled. They cost more then in US because the importer has to pay customs fee of about 150 us$, and the price of iPad here is more or less the same in all the shops with Apple's logo. The machines come in sealed boxes, and there is nothing suspicious about them. And they sell in such numbers that it would be absolutely impossible that somebody just bought iPads in US and brought them over to resell in China.
    The shop where I bought mine is one of the biggest computer malls in Beijing, and the iPad is advertised all around, by which I want to say that they don't sell it under the desk, but very prominently. Beside, I got the regular receipt for it.
    Yes, I asked about the warranty, and they told me that the shop will provide within for 1 year. Actually, I have rich experience with the Apple's repairing and maintaining service here, in Beijing, and all these shops with Apple's license have contract with it. It works fine, although I hope I will never need it again.
    Apps that they installed for me are mostly those which I would not be able to download from my Chinese iTunes account, and the books they provided with the iBooks are all Chinese works in Chinese language, which one can download free from the website. So, this part is not against copyright law. Getting these particular books on line is not a big deal, but I love using iBooks reader, and this is the main reason why I am reluctant to sync my iPad with my iTunes, and consequently lose the iBooks for ever. I don't care about any other application so much, but I wanted iPad mainly as the superb e-reader, and without iBooks, it hardly can come to being that.
    I don't know if there is a kind of a deal between Apple and its Chinese licensed dealers, but I can tell you why people still buy Apple's products in those shops like the one where I bought my iPad. Chinese government has very strict rules with everything. So, iPhone, for example, which is sold in the the official Apple Shop (there is one in Beijing too) has no WiFi, but the iPhone sold in the computer shops with Apple's license has it. I am not going to elaborate why it is so, to put it shortly - the Chinese government has problems with mobile phones with WiFi. So, what would you do if you lived here and wanted an iPhone? I bought mine in Hong Kong, with WiFi of course.
    Now, I am waiting to see how it will go on between China and Apple, and what will be allowed here for download. Till now we cannot buy music from the Chinese iTunes store! I am afraid that this will be the case with books too. So, till I am sure about it, I will be using this iPad with the iBooks installed in the shop for me.
    I still need to figure out how to transfer the books that I have purchased before and read them on the iPad. I know that some of them I will not be able to open because of DRM, but I hope that some others I will be able to transfer and read on this fabulous iBooks reader. If anyone still wants to help me with suggestions how to do that, it would be very appreciated!
    Sorry for my long reply, and thanks again!

  • I must be doing something wrong, but I can't find it.

    Hi all.
    I had this code working two or three iterations ago, but in moving some functionality from one class (where it did not belong) to another (where it made more sense to deal with it) I broke something. Below, you will see my ImageViewer class source:
    package us.state.pa.dli.imagetracker;
    import java.awt.*;
    import java.awt.image.*;
    import javax.media.jai.*;
    * @author ghurley
    public class ImageViewer extends ScrollPane {
         static final long serialVersionUID = 1;
         private ImageFile iFile;
         //private Image i;
         private Graphics2D g2;
         private BufferedImage mBufferedImage;
         private MediaTracker mt;
         public ImageViewer() {
              // TODO Auto-generated constructor stub
          * This method makes the content of the ImageViewer pane.
         public void makeContent() {
              iFile = new ImageFile("D:\\eclipse\\plugins\\com.yoxos.yim_2.2.2\\yoxos32.png");
              mt = new MediaTracker(this);
              this.renderImage();
              this.setVisible(true);
         public void replaceImage(ImageFile imFile) {
              //mt.removeImage(i);
              mt.removeImage(mBufferedImage);
              this.iFile = imFile;
              this.renderImage();
              this.repaint();
         public void renderImage() {
              String name = iFile.getAbsolutePath();
              //BufferedImage mBufferedImage = iFile.getB();
              this.loadOther(name);
             if (mBufferedImage.equals(null)) {
    //              System.out.println("No image loaded!");
                  return;
             //System.out.println("mBufferedImage is a: "+mBufferedImage.getClass().getName());
             int x, y;
    //         System.out.println("Width: "+this.iFile.getWidth());
    //         System.out.println("Height: "+this.iFile.getHeight());
             x = this.centerImage(this.iFile.getWidth(),'x'); 
             y = this.centerImage(this.iFile.getHeight(),'y');
    //         System.out.println("x: "+x);
    //         System.out.println("y: "+y);
    //         System.out.println("scaled width: "+mBufferedImage.getWidth(this));
    //         System.out.println("scaled height: "+mBufferedImage.getHeight(this));
             if (iFile.getHeight() > this.getHeight() || iFile.getWidth() > this.getHeight()) {
                  mBufferedImage = iFile.showMeScaled();
                  System.out.println("scaling down");
    //              g.drawImage(iFile.showMeScaled(), x, y, this);
             } else if (iFile.getHeight() < this.getHeight() && iFile.getWidth() < this.getWidth()) {
                  mBufferedImage = iFile.showMeScaled();
                  System.out.println("scaling up");
    //              g.drawImage(iFile.showMeScaled(), x, y, this);
             } else {
                  mBufferedImage = iFile.showMe();
                  System.out.println("not scaling");
                  System.out.println(iFile.getName()+":\n\tWidth:"+iFile.getWidth()+"\n\tHeight:"+iFile.getHeight()+"\n\tx:"+x+"\n\ty:"+y);
                  System.out.println("This Panel:\n\tWidth:"+this.getWidth()+"\n\tHeight:"+this.getHeight());
    //              g.drawImage(iFile.getB(), x, y, this);
             this.setGraphics(mBufferedImage.createGraphics());
             g2.drawImage(mBufferedImage, 0, 0, this);
    //         System.out.println(this.g2.toString());
    //         System.out.println(mBufferedImage.createGraphics().toString());
    //         g = this.g2;
    //         g2 = this.getGraphics();
              //Graphics g2 = this.getGraphics();
              //showImage(mBufferedImage);
              if (!g2.equals(null)) myPaint();               
    //     private void showImage(BufferedImage bufferedImage) {
    //          // TODO Auto-generated method stub
         private void loadOther(String name) {
    //          double myScale;
              iFile.setQ(this);
              iFile.setSize(this.getSize());
    //          i = iFile.showThumbnail();
              mBufferedImage = iFile.showMe();
    //          myScale  = this.getScale();
    //          System.out.println(myScale);
    //          if (this.getWidth() < iFile.getWidth() || this.getHeight() < iFile.getHeight()) {
    //               iFile.setScale(myScale);
    //               mBufferedImage = iFile.showMeScaled();
              mt.addImage(mBufferedImage, 0);
    //          mt.addImage(mBufferedImage, 0);
              try {
                   mt.waitForID(0);
              } catch (InterruptedException ie) {
                   System.out.println("Oops.  Exception: " + ie.getMessage());
                   return;
         private int centerImage(int coordinate, char axis){
              int displacement = 0;
              if (axis == 'x') {
                   displacement = (this.getWidth() - coordinate) / 2;
              } else {
                   displacement = (this.getHeight() - coordinate) / 2;
              return displacement;
          * @param args
         public void myParseArgs(String[] args) {
              this.iFile = new ImageFile(args[0]);
         private void myPaint() {
              this.paint(g2);
         public void paint(Graphics2D g) {
    //         if (i.equals(null)) return;
    //         if (mBufferedImage.equals(null)) return;
    //         System.out.println("mBufferedImage is a: "+mBufferedImage.getClass().getName());
    //         int x, y;
    //         System.out.println("Width: "+this.iFile.getWidth());
    //         System.out.println("Height: "+this.iFile.getHeight());
    //         x = this.centerImage(this.iFile.getWidth(),'x'); 
    //         y = this.centerImage(this.iFile.getHeight(),'y');
    //         System.out.println("x: "+x);
    //         System.out.println("y: "+y);
    //         System.out.println("scaled width: "+mBufferedImage.getWidth(this));
    //         System.out.println("scaled height: "+mBufferedImage.getHeight(this));
    //         if (iFile.getHeight() > this.getHeight() || iFile.getWidth() > this.getHeight()) {
    //              mBufferedImage = iFile.showMeScaled();
    ////              g.drawImage(iFile.showMeScaled(), x, y, this);
    //         } else if (iFile.getHeight() < this.getHeight() && iFile.getWidth() < this.getWidth()) {
    //              mBufferedImage = iFile.showMeScaled();
    ////              g.drawImage(iFile.showMeScaled(), x, y, this);
    //         } else {
    //              mBufferedImage = iFile.showMe();
    //              System.out.println(iFile.getName()+":\n\tWidth:"+iFile.getWidth()+"\n\tHeight:"+iFile.getHeight()+"\n\tx:"+x+"\n\ty:"+y);
    //              System.out.println("This Panel:\n\tWidth:"+this.getWidth()+"\n\tHeight:"+this.getHeight());
    ////              g.drawImage(iFile.getB(), x, y, this);
    //         this.setGraphics(mBufferedImage.createGraphics());
    //         g = this.g2;
    //         g.drawImage(mBufferedImage, 0, 0, this);
              g.drawString("Hiya", 0, 0);
    //          g.drawImage(iFile.showThumbnail(), 0, 0, this);
         public Insets getInsets() {
              Insets in = super.getInsets();
              if (in ==  null) {
                   in = new Insets(0, 0, 0, 0);
              return in;
         private void setGraphics(Graphics2D g) {
              this.g2 = g;
         public Graphics2D getGraphics() {
              //WritableRaster w = iFile.getB().getRaster();
              //BufferedImage b = new BufferedImage(this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB);
              BufferedImage b = iFile.showMe();
    //          System.out.println("Height Should Be:"+b.getHeight());
              //System.out.println(g2.)
    //          g2 = b.createGraphics();
              g2 = iFile.getGraphics();
              g2.setColor(Color.BLUE);
              //g2 = (Graphics2D)g2.create(0, 0, this.getWidth(), this.getHeight());
              return g2;
    }The ImageFile class has source as follows:
    package us.state.pa.dli.imagetracker;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.awt.image.renderable.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.media.jai.*;
    import com.sun.media.jai.codec.*;
    import javax.imageio.*;
    public class ImageFile extends File {
         static final long serialVersionUID = 1;
         private String parentDir;
         private double scale;
         private int width, height;
         private double scaledWidth, scaledHeight;
         //private Image i;
         private BufferedImage b;
         private Directory d;
         private Component q;
          * @param arg0 The parent directory
          * @param arg1 The child file
          * <p>Creates a new File instance from a parent abstract pathname and a child pathname string.
         public ImageFile(File arg0, String arg1) {
              super(arg0, arg1);
              this.setParentDir(this.getParent());
              this.setScale(1.0);
              this.setImageSize();
          * @param arg0 The parent directory
          * @param arg1 The child file
          * <p>Creates a new File instance from a parent pathname string and a child pathname string.
         public ImageFile(String arg0, String arg1) {
              super(arg0, arg1);
              this.setParentDir(this.getParent());
              this.setScale(1.0);
              this.setImageSize();
          * @param arg0
          * <p>Creates a new File instance by converting the given pathname string into an abstract pathname.
         public ImageFile(String arg0) {
              super(arg0);
              this.setParentDir(this.getParent());
              this.setScale(1.0);
              this.setImageSize();
          * @param arg0
          * <p>Creates a new File instance by converting the given file: URI into an abstract pathname.
         public ImageFile(URI arg0) {
              super(arg0);
              // TODO Auto-generated constructor stub
              this.setParentDir(this.getParent());
              this.setScale(1.0);
              this.setImageSize();
    //      * @param prefix
    //      * @param suffix
    //     public void createATempFile(String prefix, String suffix) {
    //          d = new Directory(this.parentDir);
    //          try {
    //               File f = super.createTempFile(prefix, suffix,d);
    //          } catch (IOException e) {
    //               // TODO Auto-generated catch block
    //               e.printStackTrace();
    //     public ImageFile createImageFile(Image i) {
    //          ImageFile newIfile = null;
    //          ImageEncoder ie = null;
    //          File newFile;
    //          String []foundThese;
    //          String fileType = "BMP";
    //          String extension = this.getName().substring(this.getName().lastIndexOf('.'));
    //          String timestamp = "" + new java.util.Date().getTime();
    //          String myOS = System.getProperty("os.name");
    //          char mySep;
    //          if (myOS.substring(0, 7).equalsIgnoreCase("Windows")) {
    //               mySep = '\\';
    //          } else {
    //               mySep = '/';
    //          this.createATempFile(timestamp, extension);
    //          foundThese = (this.d.searchFor(timestamp));
    //          //take the first one
    //          newFile = new File(foundThese[0]);
    //          System.out.println(newFile.getPath());
    ////          int[] pixels = new int[(int)(this.scaledHeight*this.scaledWidth)];
    ////          PixelGrabber pg = new PixelGrabber(i, 0, 0, (int)scaledWidth, (int)scaledHeight,pixels,0,0);
    ////          try {
    ////               pg.grabPixels();
    ////          } catch (InterruptedException e1) {
    ////               // TODO Auto-generated catch block
    ////               e1.printStackTrace();
    //////          if(!newIfile.exists()) {
    //////               try {
    //////                    newIfile.createNewFile();
    //////               } catch (IOException e) {
    //////                    // TODO Auto-generated catch block
    //////                    e.printStackTrace();
    //          FileOutputStream fos;
    //          try {
    //               fos= new FileOutputStream(newFile);
    //               if (extension.equalsIgnoreCase(".TIF") || extension.equalsIgnoreCase(".BMP")) {
    //                    TIFFEncodeParam tep = new TIFFEncodeParam();
    //                    fileType = "TIFF";
    //                    ie = (ImageEncoder)new com.sun.media.jai.codecimpl.TIFFImageEncoder(fos, tep);
    //               } else if (extension.equalsIgnoreCase(".BMP")) {
    //                    BMPEncodeParam bep = new BMPEncodeParam();
    //                    ie = (ImageEncoder)new com.sun.media.jai.codecimpl.BMPImageEncoder(fos, bep);
    //               } else if (extension.equalsIgnoreCase(".PNG")) {
    //                    PNGEncodeParam pep = new PNGEncodeParam.Palette();
    //                    fileType = "PNG";
    //                    ie = (ImageEncoder)new com.sun.media.jai.codecimpl.PNGImageEncoder(fos, pep);
    //               } else if (extension.equalsIgnoreCase(".GIF")) {
    //                    System.out.println("GIF Images not supported");
    //               } else if (extension.equalsIgnoreCase(".JPG")) {
    //                    JPEGEncodeParam jep = new JPEGEncodeParam();
    //                    fileType = "JPEG";
    //                    ie = (ImageEncoder)new com.sun.media.jai.codecimpl.JPEGImageEncoder(fos, jep);
    //               } else {
    //                    System.out.println("File format not supported");
    //          } catch (FileNotFoundException e) {
    //               // TODO Auto-generated catch block
    //               e.printStackTrace();
    //          ImageWriter iw = (ImageWriter)ImageIO.getImageWritersBySuffix(extension.substring(1)).next();
    //          ParameterBlock jpb = new ParameterBlock().addSource(i);
    //          OperationRegistry ory = JAI.getDefaultInstance().getOperationRegistry();
    //          String [] temp = ory.getRegistryModes();
    //          String []temp2;
    //          for (int which = 0; which < temp.length; which++) {
    //               temp2 = ory.getDescriptorNames(temp[which]);
    //               System.out.println("\t"+temp[which]+":");
    //               for (int cual = 0; cual < temp2.length; cual++) {
    //                    System.out.println("\t\t"+temp2[cual]);
    //          ParameterBlock scaler = new ParameterBlock().addSource(i);
    //          scaler.add(newFile);
    //          scaler.add(new Dimension((int)this.scaledWidth, (int)this.scaledHeight));
    //          RenderableOp scaleIt = new RenderableOp("scale",scaler);
    //          AffineTransform at = new AffineTransform();
    //          RenderContext rc = new RenderContext(at);
    //          RenderedImage ri = scaleIt.createRendering(rc);
    //          try {
    //               jpb.set(ImageIO.createImageOutputStream(newFile), 0);
    //               jpb.set(Boolean.TRUE, 5);
    //               jpb.set(new Dimension((int)this.scaledWidth, (int)this.scaledHeight),6);
    //               jpb.set(iw, 13);
    //               //System.out.println(JAI.getDefaultInstance().getOperationRegistry())
    //               RenderedOp op = JAI.create("FileStore", jpb);
    //          } catch (IOException e) {
    //               // TODO Auto-generated catch block
    //               e.printStackTrace();
    ////          RenderedOp op = JAI.create("filestore", i,foundThese[0],fileType);
    ////          RenderedOp op = JAI.create("filestore", image, filename, filetype, encodeParam);
    //          //          if (! ie.equals(null)) {
    ////               newIfile = new ImageFile(fred[0]);
    ////               RenderedImage ri = newIfile.getB();
    ////               try {
    ////                    ie.encode(ri);
    ////               } catch (IOException e) {
    ////                    // TODO Auto-generated catch block
    ////                    e.printStackTrace();
    //          newIfile = new ImageFile(newFile.getPath());
    //          return newIfile;
          * @return A URI representing this file.
         public URI getURI() {
              return this.toURI();
         public URL getURL() {
              URL u = null;
              try {
                   u = this.getURI().toURL();
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              //System.out.println(u);
              return u;
         public boolean matchFileName(String namePart) {
              boolean matches = false;
              matches = this.getPath().contains((CharSequence)namePart);
              return matches;
         public String getParentDir() {
              return this.parentDir;
         public void setParentDir() {
              int endIndex = this.getPath().lastIndexOf(File.pathSeparatorChar);
              this.setParentDir(this.getPath().substring(0, endIndex));
         public void setParentDir(String pathName) {
              this.parentDir = pathName;
         public void move(String newpath) {
              //String myPath = this.getPath();
              String myName = this.getName();
    //          System.out.println(myName);
              //char sep = File.pathSeparatorChar;
              String newName = "";
              //int startName = myPath.length();
              //newName =newName + newpath + sep + myName;
              newName =newName + newpath + myName;
    //          System.out.println(newName);
              File f = new File(newName);
              this.renameTo(f);
    //     public Image show() {
    //          i = Toolkit.getDefaultToolkit().getImage(this.getPath());
    //          System.out.println(Toolkit.getDefaultToolkit().getImage(this.getPath()).toString());
    //          return i;          
         public Image showThumbnail() {
              Image i;
              //this.showMeScaled();
    //          System.out.println("Image width: "+width);
    //          System.out.println("Image height: "+height);
    //          System.out.println(b);
              i = b.getScaledInstance((int)scaledWidth, (int)scaledHeight, Image.SCALE_AREA_AVERAGING);
              System.out.println(i);
              return i;     
         public BufferedImage showMeScaled() {
              BufferedImage b;
              //b = showMe();
              RenderedOp ro = JAI.create("fileload", this.getPath());
              PlanarImage pi1 = ro.getNewRendering();
              //ParameterBlock params = new ParameterBlock().addSource(b);
              ParameterBlock params = new ParameterBlock().addSource(pi1);
              //HashMap hm = new HashMap();
              params.add((float)this.getScale());     // x
              params.add((float)this.getScale());     // y
              params.add((float)this.width);
              params.add((float)this.height);
              params.add(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
    //          ImageLayout il = new ImageLayout(b);
    //          il.setHeight((int)this.scaledHeight);
    //          il.setWidth((int)this.scaledWidth);
              RenderedOp scaled = JAI.create("Scale", params);
              b = scaled.getAsBufferedImage();
    //          System.out.println(b.getHeight());
    //          System.out.println(b.getWidth());
    //          BufferedImage b = showMe();
    //          //Image temp = this.show();
    //          //height = i.getHeight(q);
    //          if (height <= 0) height = q.getHeight();
    //          //width =  i.getWidth(q);
    //          if (width <= 0) width = q.getWidth();
    //          System.out.println("Height: "+height+", Width: "+width);
    //          this.scaleImage();
              //temp = i.getScaledInstance(width, height, BufferedImage.SCALE_AREA_AVERAGING);
              //b = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
              //i = temp;
    //          b = (BufferedImage)i.getScaledInstance(width, height, BufferedImage.SCALE_AREA_AVERAGING);
    //          b.getScaledInstance(width, height, BufferedImage.SCALE_AREA_AVERAGING);
              //b.getSubimage(x, y, w, h)
              //Image temp = b.getScaledInstance(width, height, BufferedImage.SCALE_AREA_AVERAGING);
              //b = (BufferedImage)temp;
              return b;
         public BufferedImage showMe() {
              RenderedOp ro = JAI.create("fileload", this.getPath());
              b = ro.getAsBufferedImage();
              height = ro.getHeight();
              width = ro.getWidth();
              return b;
    //     private void scaleImage() {
    //          this.height = (int)((double)this.height * this.scale);
    //          this.width = (int)((double)this.width * this.scale);
          * @return the scale
         public double getScale() {
              return scale;
          * @param scale the scale to set
         public void setScale(double scale) {
              this.scale = scale;
          * @return the q
         public Component getQ() {
              return q;
          * @param q the q to set
         public void setQ(Component q) {
              this.q = q;
          * @return the b
         public BufferedImage getB() {
              return b;
          * @param b the b to set
         public void setB(BufferedImage b) {
              this.b = b;
          * @return the height
         public int getHeight() {
              return (int)this.scaledHeight;
          * @return the width
         public int getWidth() {
              return (int)this.scaledWidth;
          * @param height the height to set
         private void setHeight(int height) {
              this.scaledHeight = (double)height;
          * @param width the width to set
         private void setWidth(int width) {
              this.scaledWidth = (double)width;
         private int makeInt(double rate) {
              int iOut;
              iOut = (int) (1000000.0 * rate);
              return iOut;
         public void setSize(Dimension d) {
              this.setHeight(d.height - 20);
              this.setWidth(d.width - 20);
              double temp;
              double ratio1, ratio2;
              ratio1 = (double)this.height / (double)this.width;
              ratio2 = (double) (this.scaledHeight / this.scaledWidth);
              if (makeInt(ratio2) >= makeInt(ratio1)) {
                   temp = (double)this.scaledWidth / (double)this.width;
                   this.setScale(temp);
              } else {
                   temp = (double)this.scaledHeight / (double)this.height;
                   this.setScale(temp);               
              this.setSize((int)(scale*(double)width), (int)(scale*(double)height));
         public void setSize(int width, int height) {
              this.setWidth(width);
              this.setHeight(height);
         public Dimension getSize() {
              Dimension d = new Dimension();
              d.setSize(this.width, this.height);
              return d;
         private void setImageSize() {
              this.b = this.showMe();
              this.setImageHeight();
              this.setImageWidth();
              this.setHeight(this.height);
              this.setWidth(this.width);
         private void setImageHeight() {
              this.height=b.getHeight();
         private void setImageWidth() {
              this.width=b.getWidth();
         public ColorModel getColorModel() {
              return b.getColorModel();
         public Graphics2D getGraphics() {
              return b.createGraphics();
          * @return the d
         public Directory getD() {
              return d;
          * @param d the d to set
         public void setD(Directory d) {
              this.d = d;
    }My problem is in the display of the image, though, so only the first class is really necessary, but I was wondering if my computations of the size of the BufferedImage could have caused my problems. Additionally, this code seems to choke when displaying large TIFF files, such as those downloaded from NASA's website. My application will not use such large TIFF files, but it gives me a perfect testing ground. The error I get when loading such files is a "Java-AWT:Event Error" involving the "Memory Heap". Can someone familiar with the JAI let me know what I am doing wrong? This worked well without using JAI functionality to scale the BufferedImage, but when I tried to do that, it freaked on me with the display. I get a blank panel. System.out.println() commands are inserted to report status, and commented lines are from earlier attempts.
    Thanks,
    Garry

    Well, I'll be damned, it seems I need to copy an object on
    ALL the frames and make it Alpha 0% if I want the object to be
    accessible through ActionScript. I actually got 5 frames and if I
    only put it on the first frame, it won't be null but mouseDown
    eventListener won't work... Hmmm that's the first thing I find that
    looks like a patch with ActionScript 3.

Maybe you are looking for

  • CRM : creation of service in transaction COMMPR01

    Hi  Experts                 Can anyone tell me how to create a service in transaction COMMPR01  and also the BAPI or function modules used to create service in CRM . Thanks & Regards.

  • Trusteer Rapport icon no longer appears in address bar since upgrading to Firefox 9.

    I used to have Firefox 7 and the Trusteer Rapport icon used to appear in the address bar. Now I have upgraded to Firefox 9 the icon no longer appears, which is annoying.

  • Converting normal FM to RFC

    Hi All I am converting normal FM  to ZRFC. My normal FM- BBP_GET_UNITS_F4 has table parameters with table type. In RFC table type is not allowed and i changed the tables parameter into structure. Now inside my ZRFC, i am calling the normal FM. Here i

  • Who has the answer to email in iPhoto?

    who can get the email to work from iphone? please let us know because I have a case open and we still can't get it fixed. To save your typing. It is not my prefernces, u/n-password, or configurations in iphoto. It is done right. I re-entered it a tho

  • [Photoshop CC] Gepunktetes Raster zieht sich nicht über das ganze Bild, sichtbar.

    Hallo, ich nutze das gepunktete Raster für ein Projekt derzeit. Mit einem Rasterlinie auf 10 und Unterteilungen auf 1. Jedoch zieht sich das Raster nur über das erste Viertel des Bildes. Je höher ich die Rasterlinie setze desto weiter erstreckt es si