Uncaught error fetching image? Help appreciated.

Hello. I'm currently working on a simple game that is quite similar to Minesweeper. There are 25 JPanels that show an image when they are clicked, the object being to find all the gophers. Everything is working fine, but for some reason I'm getting an error when an image tries to load. This happens randomly throughout the game, with some loading and then crashing when the error appears. The error I get is the following:
Uncaught error fetching image:
java.lang.NullPointerException
        at java.io.FileInputStream.<init>(FileInputStream.java:103)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at sun.awt.image.FileImageSource.getDecoder(FileImageSource.java:35)
        at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:240)
        at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
        at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)I'm currently using a modified version of Random that someone created, that makes sure values in a certain range are not repeated, to assign strings containing the image file's name randomly across the JPanels. Here's the method that I'm using to assign the strings:
    public void Generate() {
        for(int i = 0; i <= 24; i++) {
            if(i < maxGophers)
                imageName = "gopher.jpg";
            else if(i < maxGophers+maxWolves && wolvesJCheckBox.isSelected())
                imageName = "wolf.jpg";
            else if(i > maxGophers)
                imageName = "hole.jpg";
            switch(generator.getNextInt(26)) {
                case 1: panel1 = imageName;
                        break;
                case 2: panel2 = imageName;
                        break;
                case 3: panel3 = imageName;
                        break;
                case 4: panel4 = imageName;
                        break;
                case 5: panel5 = imageName;
                        break;
                case 6: panel6 = imageName;
                        break;
                case 7: panel7 = imageName;
                        break;
                case 8: panel8 = imageName;
                        break;
                case 9: panel9 = imageName;
                        break;
                case 10: panel10 = imageName;
                        break;
                case 11: panel11 = imageName;
                        break;
                case 12: panel12 = imageName;
                        break;
                case 13: panel13 = imageName;
                        break;
                case 14: panel14 = imageName;
                        break;
                case 15: panel15 = imageName;
                        break;
                case 16: panel16 = imageName;
                        break;
                case 17: panel17 = imageName;
                        break;
                case 18: panel18 = imageName;
                        break;
                case 19: panel19 = imageName;
                        break;
                case 20: panel20 = imageName;
                        break;
                case 21: panel21 = imageName;
                        break;
                case 22: panel22 = imageName;
                        break;
                case 23: panel23 = imageName;
                        break;
                case 24: panel24 = imageName;
                        break;
                case 25: panel25 = imageName;
                        break;
            } // end switch
        } // end for
    } // end method Generate{code}This is the code I'm using to load the images once the JPanels are clicked:
{code:java}        imageIcon = new ImageIcon(panel1);
        image = imageIcon.getImage();
        Graphics g = blankJPanel1.getGraphics();
        g.drawImage (image, 1, 1, blankJPanel1);{code}There's also a JButton that draws all the associated images on all the panels, but that gives the error as well, drawing only some until it encounters it.
I'm quite sure this isn't the most efficient way to go about it, so I'm open to any changes and suggestions. Thanks to anyone who can help!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

There are 25 JPanelsYou need to hold them in an array. All that panel1, panel2, ... panel25 business is a waste of time and space.
java.lang.NullPointerExceptionSo something is null that shouldn't be.
imageIcon = new ImageIcon(panel1);
image = imageIcon.getImage();
Graphics g = blankJPanel1.getGraphics();
g.drawImage (image, 1, 1, blankJPanel1);i.e. one of those variables.

Similar Messages

  • Help me this error :"uncaught error fetching image" with Jar file

    Hi all.
    I have a program written with Swing. This program has one button and fetch Image into this button. Image is in Images directory .When I run this program by IDE, It's OK. However, when I compress classes of this program into Jar file and run, it can not recognize the path to Image. And it leads to this error:
    "uncaught error fetching image"
    I have tried to look for a lot of information relating to this problem on the internet but nothing is possible.
    Please help me. Thank you.
    And my program
    http://www.mediafire.com/?j0yzun4d0mx

    When you JAR it's different. Try something like this:
    BufferedReader br=new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(listname)));
    you don't hae to do the BufferedReader, but the getClass().getResource... is what you need.

  • Help me this error :"uncaught error fetching image"

    I have a program written with Swing. This program has one button and fetch Image into this button. Image is in Images directory .When I run this program by IDE, It's OK. However, when I compress classes of this program into Jar file and run, it can not recognize the path to Image. And it leads to this error:
    "uncaught error fetching image"
    I have tried to look for a lot of information relating to this problem on the internet but nothing is possible.
    Please help me. Thank you.
    And my program
    http://www.mediafire.com/?j0yzun4d0mx

    Read the Swing tutorial on [How to Use Icons|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]. It shows you how to load images from a jar file.

  • Uncaught error fetching image: java.lang.NullPointerException

    Hi everybody,
    I am developing standalone application using NetBeans,the aplication is running fine in netbeans IDE but not when Jar alone tried to run.I kept all the files related to application with the jar.
    when running jar,the app is running fine upto some extent,and throwing exception at the time of fetching images from images folder which is placed inside "src folder"
    class files package and images folder are in the src folder. the code is like this:
    mLogo = new JLabel();
            URL lUrlLogo =  getClass().getResource("/images/eaze.gif");
            System.out.print(lUrlLogo);
            Image lLogoimage = Toolkit.getDefaultToolkit().createImage(lUrlLogo);//.getImage(lUrlLogo);
            ImageIcon licon = new ImageIcon(lLogoimage);
            mLogo.setIcon(licon);i tried by using Mainclass.class.getResource("/images/eaze.gif");
    and also by using thread but dint solved
    The exception is like this:
    Uncaught error fetching image:
    java.lang.NullPointerException
    at sun.awt.image.URLImageSource.getConnection(URLImageSource.java:99)
    at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:113)
    at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:240)
    at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
    at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)

    don't specify an absolute path line "/images/eaze.gif" but use a relative path like "images/eaze.gif" or you might need the complete package path.

  • Uncaught error fetching image

    Hi all,
    It seems that my GNOME Terminal can't open a window with Java (JRE 1.5 update 6) when I call a java-dependent software. I get this kind of error messages:
    Uncaught error fetching image:
    java.lang.NullPointerException
            at sun.awt.image.URLImageSource.getConnection(Unknown Source)
            at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
            at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
            at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
            at sun.awt.image.ImageFetcher.run(Unknown Source)Someone? Any clue?
    Thanks a lot for time and experience.
    Manu

    which image is involved here? an image provided by my
    application software, or by JRE?
    what can I do to make it open this image?
    manu
    PS: I also tried with Xterm, but I receive the same
    error messagesHard to say. The image does probably not belong to the JRE. I guess you need to debug the application.
    Kaj

  • What is Uncaught error fetching image ?

    Hi,
    I am using Netbeans 5.5.1 with JDK 6 bundle and trying to build an GUI application but I am getting strange error like this when I try to compile and run:
    =====================================================
    Uncaught error fetching image:
    java.lang.NullPointerException
    at sun.awt.image.URLImageSource.getConnection(URLImageSource.java:97)
    at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:107)
    at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:240)
    at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
    at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
    =====================================================
    I tried to debug but I was not able to. It happens even before the first line of code executes?
    What is this error and how can I fix this?
    Thanks

    Well I have one image loaded in label and one in a button. Both loaded as classpath. I have tried to set the image as null (no image) but it still shows the same error. However I can build my application without error. This error shows only if tried to run from within the IDE. Built jar file can be executed from outside the IDE.

  • Update Terminated Error in Va01-Help Appreciated

    Hi ,
        When I create Sales Order in Va01  for order type ZCS,ZCD, and when i try to view that in Va02- It gives "UPDATE Terminated " from author .
    I have already posted this in sdn before and i got the solution to check in ST22.
    I have found the FM that caused the error.This parameter ord_pre_imp was empty as there were no order number.
    CALL FUNCTION 'CO_BH_ORD_HEADER_PRE_READ'
           EXPORTING
                client              = client
                number_of_tasks     = number_of_tasks
                flg_ordnet_exploded = explode_ord_net
                flg_enq_set         = flg_set_enq
                import_message_id   = import_message_id
                caufv_single_imp    = caufv_single_imp
                trtyp_net           = trtyp_imp
                flg_no_gos          = flg_no_gos
                flg_called_to_copy  = flg_called_to_copy
           IMPORTING
                flg_ordnet_read     = flg_ordnet_read
           TABLES
                aufpl_tab           = aufpl_tab
                ord_pre_tab         = ord_pre_imp
                bedid_tab           = bedid_tab
                rsnum_tab           = rsnum_tab
                number_tab          = number_tab
                autab_tab           = autab
           EXCEPTIONS
                not_found           = 01.
      IF NOT sy-subrc IS INITIAL.
        RAISE not_found.
      ELSE.
    Need to know whether error due to configuration or technical.  what i should do in this case.
    U'r Help will be appreciated. Thanks in advance

    Hi,
    Check the error analysis in the ST22. Here you get the complete error analysis.
    Furthermore if you want to check the updation error, then go to SM13 and see the update error analysis.
    Hope this information helps you.
    Regards.
    Deepak SHarma.

  • Af:menu does not render image - Help appreciated

    <af:commandToolbarButton id="exportBtn" immediate="true">
    <f:facet name="popup">
    <af:menu icon="/icons/exporttoexcel_ena.png" id="m1">
    <af:commandMenuItem text="Export All" id="exa" >
    <af:exportCollectionActionListener type="excelHTML" exportedId="t1"
    filename="export.xls" exportedRows="All" title="ADF Faces Export"/>
    </af:commandMenuItem>
    <af:commandMenuItem text="Export Selected" id="exs" >
    <af:exportCollectionActionListener type="excelHTML" exportedId="t1"
    filename="export.xls" exportedRows="selected" title="ADF Faces Export"/>
    </af:commandMenuItem>
    </af:menu>
    </f:facet>
    </af:commandToolbarButton>
    Why wouldn't image get rendered ? I have checked the image file is present and the location... I tired adding the same image to another component and it worked.
    if I add image to commandToolbarButton it works. something like this:
    <af:commandToolbarButton icon="/icons/exporttoexcel_ena.png" id="exportBtn" immediate="true">
    <f:facet name="popup">
    <af:menu id="m1">
    <af:commandMenuItem text="Export All" id="exa" >
    <af:exportCollectionActionListener type="excelHTML" exportedId="t1"
    filename="export.xls" exportedRows="All" title="ADF Faces Export"/>
    </af:commandMenuItem>
    <af:commandMenuItem text="Export Selected" id="exs" >
    <af:exportCollectionActionListener type="excelHTML" exportedId="t1"
    filename="export.xls" exportedRows="selected" title="ADF Faces Export"/>
    </af:commandMenuItem>
    </af:menu>
    </f:facet>
    </af:commandToolbarButton>
    Problem with this is there is a line(separator) between commandToolbarButton and the menu icon(down arrow). Is there a work around to remove the separator ?

    Have you tried setting the actionDelivery="none" on the af:commandToolbarButton in order to get rid of the line?

  • Error creating image

    Im getting error when trying to create an image from array
    when i am reading the image as array from the network
    public void write(OutputStream out) throws IOException{
        DataOutputStream dout = new DataOutputStream(out);
        //Write mood name
        dout.writeUTF(m_moodName);
        if(m_img == null){
          //Write there is no image
          dout.writeBoolean(false);
        }else{
          //Write there is image
          dout.writeBoolean(true);
          PngEncoder pngEncoder = new PngEncoder(m_img);
          byte[] array = pngEncoder.pngEncode();
          //Write the array length
          dout.writeInt(array.length);
          //Write the array
          dout.write(array);
          dout.flush();
      public void read(InputStream in) throws IOException{
        DataInputStream din = new DataInputStream(in);
        //Read mood name
        m_moodName = din.readUTF();
        //Read if there is image
        boolean bool = din.readBoolean();
        if(bool == true){
          //Read byte array length
          int length = din.readInt();
          byte[] array = new byte[length];
          //Read to byte array
          din.readFully(array);
          m_img = Toolkit.getDefaultToolkit().createImage(array);
      }This is the exception that i am getting
    Uncaught error fetching image:
    java.lang.NegativeArraySizeException
         at sun.awt.image.PNGImageDecoder.produceImage(Unknown Source)
         at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
         at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
         at sun.awt.image.ImageFetcher.run(Unknown Source)I am getting this error from this line... (i think)
    m_img = Toolkit.getDefaultToolkit().createImage(array);and here is PNG encoder that i am using
    http://catcode.com/pngencoder/
    please help...
    shay

    There are many possible reasons, for example:
    - pngEncoder produces wrong result.
    - byte array is corrupted on transition.
    I'd suggest to save this byte array as file and check if this image can be open by any image viewer.
    Also, it seems Image I/O is applicable in your scenario.
    Consider using it because it is recomeded API to work with images nowadays
    (unless you have something ImageIO can not handle, e.g. animated images)

  • HT1212 I am unable to get our of a continuous cycle when trying to update or restore my iPad 2. Plug in to iTunes 12.0.1 (latest version). Click update, told can't update, have to restore. Restore fails with error 9. Any help appreciated.

    When I tried to update my iPad I got an error 9. Now, I am unable to access my iPad. It is in a continuous cycle when I try to update or restore the iPad 2. Plug in to iTunes 12.0.1 (latest version). Click update, told can't update, have to restore. Restore fails with error 9. Any help appreciated.
    Here's the cycle:
    I plug in my iPad when “cable to iTunes shows on iPad screen. It says "Your iPad can't be updated, you must restore it to factory settings." That bad enough news, but it gets worse.
    Click Restore
    Extracting software…
    Preparing iPad for restore
    Waiting for iPad…
    Verifying iPad restore with Apple…
    (empty bar under the Apple logo…does not show any activity)
    “The iPad “iPad” could not be restored. An unknown error occurred (9).”
    Notes: I just upgraded to OS X Yosemite 10.10.1 on my iMac (27-inch, Mid 2011) in the last week. It’s the first time I’m tried to backup/update my iPad since the iMac update.
    I swapped out the USB cable to a new cable and get the same results.
    I also unplugged all other USB devices from the iMac and security on my iPad and still get the same results.
    I find it strange that it shows no Serial number for my my iPad 2 when plugged in. It shows “Serial Number: n/a on the screen when it displays: “iPad Recovery Mode To update your iPad without erasing its contents, click Update. To restore your iPad to its factory settings, click Restore iPad.
    I prefer to update my iPad, but it displays “Your iPad can’t be updated, you must restore it to factory settings. If you previously backed up the iPad, click Restore Backup after the restore process completes.”
    It’s a continuous loop. I get the display on my iPad to plug in the iPad to iTunes, plug it in which ends after going through the above procedure saying an error occurred (9).
    So now I cannot use my iPad. When I turn it on I get the display showing me to plug it into iTunes with the cable. Since this is the only option I have I plug it in and the loop begins.
    Any advice would be appreciated.
    Thanks!

    Hello jaybearden,
    Thanks for the question. After reviewing your post, it sounds like you are not able to restore the iOS device since you get an error 9. I would recommend that you read this article, it may be able to help the issue.
    Resolve iOS update and restore errors - Apple Support
    Check your security software
    Related errors: 2, 4, 6, 9, 1000, 1611, 9006. Sometimes security software can prevent your device from communicating with either the Apple update server or with your device.
    Check your security software and settings to make sure that they aren't preventing a connection to the Apple servers.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • I can no longer attach files to my outgoing Hotmail emails.  I only receive a message that an  error has occurred. Help appreciated.

    I can no longer attach files to my outgoing Hotmail emails.  I only receive a message where I would expect the Upload to appear that an  error has occurred.
    I am using a MacBook Pro with Retina, 2 Ghz Intel Core i7, OS X 10.9.4
    I have no difficulty attaching files to the outgoing Hotmails on the same account using my iPhone.
    Help appreciated.

    Thanks for this - not an immediate solution I fear but will keep unplugging stuff and restarting stuff.
    To try and be clearer about the problem - I have in the last managed to send attachments successfully.  Now  I can send and receive plain email messages but get the error message when I try to attach an existing file to an email - not just a particular file but it would appear all files are being treated in the same way. 
    An experiment to send a mail to which an attachment has failed to upload got the following message alongside the SEND button
    Files with errors will be removed from the email and not sent.
    - but the mail alone was sent and received successfully.  Thanks for any pointers you can give me. 

  • Any help appreciated - - on barefoot ski image optimization

    Any help appreciated.
    Working with Photoshop 7.0 trying to color correct and optimize an image of my son barefooting to prepare for giant vinyl print to create a stand up cut-out on a foam board.
    I will attach 2 downsized images for comparison.
    As you can see one image has nice smile but no sunlight and other image has great sunlight but no smile.
    I need to optimize for CMYK printing the smiling image. I know a bit about levels, but don't know what to change for midtones, highlights, etc. to try and correct this smiling image as best possible.
    Unfortunately I did not set up the Canon EOS Xsi camera to save RAW images at 17 megs and the boat owner is not wanting to go out again for another photo session. Original image is 4.5 megs jpg which I crop image, adjust histogram by "sliding in the sides", convert to CMYK, sharpen unmask at 98%, increase brightness with middle slider in histogram, expand size up to 72 inches tall by 54 inches wide and also set to 150 pixels per inch (may try 300), save as LZW TIFF.
    After that image is like 400 megs, then import into illustrator CS and tile out just the face of a 72 inch X 54 inch and it's amazing pretty clear for 100:1 file size increase (13 X 9 inch sheet).
    I have access to CS4 on Mac only  - - don't know if CS4 Mac file will have any big advantages over my 7.0 in Windows . . .

    Hmmmm, wonder if anybody ever created a plug in for photoshop that allowed you to add more lighting to an image, as in light coming from behind the photographer - - like sunlight effects ?

  • When I attempt to connect to iTunes Store, I receive the following error message: An unknown error has occurred (0x80090318).  Any help appreciated!

    When I attempt to connect to iTunes Store, I receive the following error message: An unknown error has occurred (0x80090318).  Any help appreciated!

    Hey there Dan256162,
    I understand that you are receiving a specific error code when attempting to connect to the iTunes Store, error 0x80090318. I have an article for you that references this code and links you to another article for troubleshooting to address this issue. Here is the article that references the error code:
    iTunes: Possible iTunes Store errors - Apple Support
    http://support.apple.com/en-us/HT203174
    And here is the linked troubleshooting article that will help you resolve the issue:
    Apple software on Windows: May see performance issues and blank iTunes Store - Apple Support
    http://support.apple.com/en-us/TS4123
    Take care, and thanks for visiting the Apple Support Communities.
    Cheers,
    Braden

  • Netweaver 2004s Preview Installation Error - Any Help Appreciated.

    Trying to install the Netweaver 2004s Preview Edition.
    The following error (in the log file) occurs after pointing to the Java Cryptographic Extension Policy Archive (zip) file and clicking 'next'.
    ===============================================
    ERROR 2007-01-04 00:26:04
    FJS-00003  TypeError: this._name has no properties (in script NW_Java_OneHost|ind|ind|ind|ind, line 8987: ???)
    ERROR 2007-01-04 00:26:21
    FCO-00011  The step collect with step key |NW_Java_OneHost|ind|ind|ind|ind|0|0|NW_Onehost_System|ind|ind|ind|ind|1|0|NW_GetSidNoProfiles|ind|ind|ind|ind|1|0|collect was executed with status ERROR .
    ===============================================
    Any help is appreciated.
    Rajendra.

    Hi,
        Drop me a mail to [email protected] I will send you the NW04s installation guide.
    regards,
    Ranjeet

  • Purchased a new Macbook Pro 13". I used migration assistant to transfer. I can't backup to time capsule.  I am getting on error The backup disk image "/Volumes/Herb's Time Capsul/Herb MacBook Pro.sparsebundle" could not be created (error 17).  Help

    Purchased a new Macbook Pro 13". I used migration assistant to transfer. I can't backup to time capsule.  I am getting on error "The backup disk image “/Volumes/Herb's Time Capsul/Herb MacBook Pro.sparsebundle” could not be created (error 17).  Help!

    Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Keychain Access in the page that opens.
    Select the System keychain in the list of keychains in the sidebar of the window. If you don't see the list, click the down-arrow icon below the sidebar.
    Then select Passwords in the Category list at lower left. Click the Kind heading in the list of keychain items to arrange it by Kind.
    Locate the AirPort Disk Password with the name of your Time Capsule. Double-click the item and check the box marked Show Password in the inspector window that opens. You'll be prompted for the administrator login password. Make a note of the AirPort password, then close the inspector window and delete the item.
    Also delete any other AirPort DIsk Password items for that same Time Capsule, which may have had a different name in the past.
    Quit Keychain Access and try again to back up.

Maybe you are looking for

  • How to configure AnyConnect ACL's?

    I am a little new to Cisco ASA's but we bought two new 5540's to use as a new VPN solution for our company. We want to implement Cisco Anyconnect full client and Clientless based solutions for our end users. I am having problems working with setting

  • Smartform DUMP|||

    Hi all, this is the error i am getting.... What happened?     Error in ABAP application program.     The current ABAP program "ZTEST_VKR" had to be terminated because one of the     statements could not be executed.     This is probably due to an err

  • SOAP to RFC - Sync Scenario. How to find where the response is going to?

    Hello All I have a SOAP to RFC sync scenario. In SXMB_MONI,  i see that both the initial message and the response message are successfully processed. But, the SOAP sender is not receiving the response message. How can i trouble shoot this scenario? H

  • GFS on Linux?

    Hello - I have a standard "Oracle only" cluster stack running my RAC cluster. Dev is now giving a requirement that they want an app server to be able to communicate with the RAC nodes via a GFS clustered file system. This is for handling files that w

  • I am in Canada but I want to get iPad2 on the 11th of March

    It is releasing on 26th in Canada but I want to get it earlier. sorry, no patience . Would it be possible to go to a a local store in Niagra falls, NY or Buffalo and get it from there? I want to get the 3g version. Just want to make sure it will work