[3912] in java-interest

home help back first fref pref prev next nref lref last post

Help !

daemon@ATHENA.MIT.EDU (Andy Cobley)
Fri Dec 1 16:55:26 1995

Date: Fri, 1 Dec 95 12:22:34 GMT
To: java-interest@java.Eng.Sun.COM
From: acobley@mic.dundee.ac.uk (Andy Cobley)

Ok, 

I am new to all this so I hope this is acceptable use of the list.
I am just getting into this java programming but have hit that brick wall
type thing.  Could someone please have a look at the code below and tell me
whats wrong.  Whenever I runit I get the Exception "failed to load picture"

So first of all 

1:  Is this code even nearly correct ?
2:  How do I find what the actual error is (kinda like perror in C)

Thanks for your time !

Andy C
----------------------------------------------------------------------

import java.awt.Graphics;
import java.awt.Image;
import java.net.*;

class SaleableObject extends java.applet.Applet{
   private int price;
   private String Name; 
   private String Picture;
   private int x,y;  
   private int width=50;
   private int height=50;
   private URL ImageURL;
   private Image myImage;

 

   public int getPrice(){
        return(price);
   }

   public String getName(){
        return(Name);
   }

   public void DisplayObject(Graphics context){
       context.drawString(Name,x,y) ;
   }

   SaleableObject() {}


   SaleableObject(int NewPrice, String newName, int newX, int newY,String
PicyName){
      price=NewPrice;
      Name=newName;
      x=newX;
      y=newY;
      Picture=PicyName;
      System.out.println("Creating Object");
      try {
         ImageURL = new URL("http","alpha.mic.dundee.ac.uk/ft/", Picture);
          
      }catch (Exception e) {
	   showStatus("Bad URL");
      }
      if (ImageURL == null)
         System.out.println("URL is Null !");

   
       if (ImageURL != null) {
       try {
           myImage = getImage(ImageURL);
       }catch (Exception e) {
           System.out.println("Failed to load picture
"+ImageURL.toExternalForm());
       }
       } 
/*	
  
*/      
   }

   public boolean IsItMe(int xpos, int ypos){

      if ((xpos > x) &&(xpos < (x+width)))
          if ((ypos > y) &&(ypos <(y+height)))
             return(true);
      return(false);
   }
}


Andy Cobley
acobley@mic.dundee.ac.uk
http://alpha.mic.dundee.ac.uk

-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post