Results 1 to 2 of 2
  1. #1
    Daryn is offline Senior Member
    Join Date
    Oct 2012
    Posts
    176
    Rep Power
    3

    Default Terminating without error whenever getClass is used

    problem sorta solved I know longer need the answer I found a way to do it without

    I have a program that is soppose to go the images folder and get an Image. the folder is located inside of the package.
    Java Code:
    characterMover.setBackground(getClass().getResource("http://www.java-forums.org/images/background.jpg"),0,0,639,511);
    The Character setBackgroundFunction is Here:
    Java Code:
    public void setBackground(URL url,int x,int y,int width, int height){
    		this.setLayout(null);
    		this.backgroundX=x;
    		this.backgroundY=y;
    		this.backgroundWidth=width;
    		this.backgroundHeight=height;
    		this.backgroundImg=new ImageIcon(url);
    		this.backgroundFImg=new JLabel(backgroundImg);
    		if(spriteAdded==true&&backgroundAdded==false){
    			backgroundAdded=true;
    			addStuff();	
    		}
    		else{ 
    			backgroundAdded=true;
    		}
    	}
    note it is NOT important to me that I use the getResource. I just want to be able to create a runnable jar that can be downloaded and runs using Images. I do not know were they are located only that they are in the same package
    Last edited by Daryn; 01-19-2014 at 09:54 AM.
    With the right know how, anything is possible

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: Terminating without error whenever getClass is used

    Sounds like you're laboring under some wrong assumptions. Let us know if you change your mind about not needing the answer.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Replies: 3
    Last Post: 07-07-2012, 06:27 AM
  2. getClass().getResource()
    By forwardbias in forum AWT / Swing
    Replies: 11
    Last Post: 03-29-2012, 04:10 AM
  3. Java getClass()
    By hqt in forum New To Java
    Replies: 2
    Last Post: 01-31-2012, 09:44 PM
  4. Replies: 6
    Last Post: 11-30-2011, 09:39 PM
  5. using getField method of getClass
    By jdigger in forum New To Java
    Replies: 2
    Last Post: 02-03-2011, 12:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •