Load pictures from a relative path

I have this type of code:
startButton.setIcon(new ImageIcon("C:\\images\\calculate.gif"));All my pics are in the images folder. How can I make the app load and display images from a relative
path. I mean if I put my jar and the images folder inside another folder the app should work on another system too.
The images folder is in the same folder as the app, and it should not matter what folder hierarchy is upper.
Inbstead of new ImageIcon("full path")  something like
new ImageIcon(new File(?relative path here));Any examples?

In all fairness, I don't think this is really a Swing question. It's about loading resources, the Swing element is incidental The OP is using an ImageIcon and JLabel, which are both only used in Swing application.
If the OP would bother to read the JLabel API they would find a link to the Swing tutorial which explains everything about loading resources.
If the OP would search the Swing forum they would find dozens of questions and answers on this topic.
The point is the OP makes very little effort to post in the appropriate forum.
Most application that use images will be using Swing. The best chance of getting an answer or finding related questions is to search/post in the forum that is most appropriate.
Its not "fair" that we waste time repeating answers to questions that are asked over and over.

Similar Messages

  • Has anyone run into the I/O error 52 when trying to load something from a relative path in extend script?

    I'm having issues when loading something in a relative path through a script, on my computer I have no issues, but on 2 other devices at work, it's not working. Even at home on a PC and mac I haven't run into problems, anyone have insight on this?
    Here's where it fails:
    #include common.jsx
    It's loading this in the same path another script is called from. Thoughts?

    I remembered we have weird permission issues at work. Somewhere between my Home Windows 8 machine(horrible permissions issues with network), my home mac, email and my work computer, some permission got out of whack. The workaround for this was copying the file to my desktop, back to the exact same spot on the network. This resolved all issues.

  • HT4101 I have used my SD card reader with the lightning connector just fine until this awful OS 7 update! Now nothing works and all I get while trying to load pictures from my SD card to my iPad is that my device is not supported!

    Anyone having the same problem with the new OS7? I can no longer load pictures from my SD card to my iPad using my adapter.

    Are the card readers apple ones or knockoffs? Unfortunately iOS7 brought with it software that looks for the authentication chip in  the cables and docks. If the manufacturer got permission from Apple to make devices then it should be fine, but if the manufacturer didn't get apple's permission then their chip isn't recognized, generating that error.
    If your connectors are Apple ones have you tried to reset your device? Hold down the sleep and home keys for about 20 seconds or so until your iPad reboots. Then try again.

  • Why can I not load pictures from a micro SD 64gb using scan disk adapter plugged into an Apple iPad camera connection kit.  I have the iPhoto app but pictures not being seen on iPad.  So incredibly frustrating.  Apple please fix this.

    Why can I not load pictures from a micro SD 64gb using scan disk adapter plugged into an Apple iPad camera connection kit.  I have the iPhoto app but pictures not being seen on iPad.  So incredibly frustrating.  Apple please fix this.

    Do you have a smaller capacity micro SD card to try? I seem to remember from past posts that users were having problems with cards larger than 32GB, however, Apple's page doesn't mention this.
    Using The iPad Camera Connection Kit
    http://support.apple.com/kb/HT4101
    What format are the pics - jpg or raw?
     Cheers, Tom

  • How can i have aperture restart loading pictures from my camera.  2 weeks ago aperture was perfect.  thursday aperture stopped loading new pics from the same camera.  have done library rebuilds and permissions to no avail.  about to trash aperture.

    How can I get aperture to restart loading pictures from my camera?  2 weeks ago; my camera (nikon D60) and aperture worked well together.  last saturtday Aperture would not upload some new photos taken that day.  I recieved an error message stating the photo files were not uploaded.  The apple store staff was no help at all this time( they usually are very good)  should i delete/trash the app and start over?

    shuttersp33d wrote:
    A bit confusing if the import window never opens, yet you receive a message that states the photos were not imported. Maybe being a little more step by step will help us figure this out:
    You plug your camera into your computer using a USB cable.
    Either Aperture is already open, or it opens automatically when you plug the camera in, or you open Aperture.
    You click on the Import button? But the import window doesn't open?
    This is where it is getting hazy for me. I'm assuming either the import window opens automatically or you click the import button. Either way you say that Aperture indicates that your camera is present and again, I'll have to assume you mean that it is present in the import window...
    Do the thumbnails from the camera appear? Are you able to check the images you would like to import? When you click the import button is when you receive the message that Aperture did not import the images?
    Let us know what is going on so we can get a better understanding. Thanks.
    Thank's for the respones.  Found out that Aperture runs great on at least 2 gig of ram.  Just installed 4 gig.  All of my issues have vanished.  Moving on the the next day.

  • How do I down load pictures from Camera Roll that were

    How do I down load pictures from Camera Roll on my iPhone to my Mac Pro that were taken prior to iCloud?

    Photos/videos in the Camera Roll can and should be imported by your computer as with any other digital camera. This was the same prior to photo streaming with iCloud and remains the same since.
    With a Mac, you can use iPhoto for the import which also supports iCloud photo streaming, or the Image Capture application.

  • HT4528 want to up load pictures from imac to iphone

    want to up load pictures from imac to iphone

    See: http://support.apple.com/kb/HT4236
    Or read the manual: http://support.apple.com/manuals/

  • How do I down load pictures from my iphone to my computer

    I can not figure out how to down load pictures from my phone to my computer, if I sync it it wants to bring all my pictures from my computer to my phone. I' am trying to clear the pics out of my phone. Thanks

    The Camera Roll on the phone identifies itself as a Digital Camera to your computer. You don't sync them as you do everything else with iTunes.
    You get them off as you would any digital camera.
    You don't say what type of computer you have so instructions are different depending on that.
    http://manuals.info.apple.com/en/iphoneuserguide.pdf
    The manual tells you how.

  • How do i load pictures from my mac to a sd card?

    how do i load pictures from my mac to a sd card? I loaded my dad's old slides to my computer , edited them, now I want to load on a SD card for a digital picture frame.  Lost.

    FAT is not an image format. It's a volume format. It sounds like your images are in iPhoto. Export them as JPEG to the Desktop, then drag them to the card in the Finder. If that doesn't work, the card is either locked or corrupt. Look for a lock switch on the side.

  • How do i load pictures from my iPhone to my apple computer

    how do i load pictures from my mac computer to my iphone5?

    Connect the phone to the computer.
    If you want to use iPhoto, launch that and then import
    If not, launch Image Capture (in the Applications Folder) and use that to move the images to yuor HD.
    Or use Photostream.
    http://support.apple.com/kb/PH2604

  • Load pictures from my camera

    load pictures from  my camera

    Hi,
    There are many ways but we need to know your existing hardware and your camera. To help us answer question quicker, please read this:
       http://h30434.www3.hp.com/t5/First-Time-Here-Learn-How-to/Welcome-Get-started-here/td-p/699035
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Cannot load pictures from Fuji F10 digital camera onto OSX 10.5.2

    I cannot load pictures from my fuji F10 digital camera. The Fuji support site does not appear to have any firmware that would allow compatibility between the two but was wondering if anyone has any ideas. I can't even bring them over using a zip drive because I get an error stating that the files are corrupt. any help is appreciated.
    Thanks,
    Chuck

    What brand of camera do you have? Perhaps you might take it up with the manufacturer, after all, they are the ones who decide whether to support mounting on the OS X Desktop.
    Given the amount of pictures I take, constantly taking my card in and out of the camera puts wear and tear on it,
    Using a USB Card Reader is a much better and safer way to transfer your photos:
    1. Less risk of your images being lost if your camera shuts down during transfer.
    2. It saves the battery on your camera
    3. It saves wear and tear on your camera ports - and replacing a worn USB port on a camera is somewhat more expensive than replacing a camera card - and what "wear and tear" is there on a card?
    4. It’s almost always faster.
    Regards
    TD

  • Not loading pictures from camera

    I am having problems with my iphoto uploading pictures from my camera. 
    When I plug my camera in my computer, it acts likes it is going to load the pictures, iphoto opens, but does not load the pictures.
    I loaded some on 12/23/11 and now today 12/25/11, it will not load anything.
    I have tried a different card, but nothing.
    Does anyone have any suggestions?
    Thanks

    I suggest fixing it
    If you would like to give us some information beyond it doe not work there is a a good chance someone can give you more advice on how to fix it
    Like what version of iPhoto - what happens, error messages, any strange that has happened, etc
    Just remember we are users just like you who know nothing except what you tell us so details are critical
    LN

  • Error message saying some of library updated use newer version when trying to load pictures from a CD

    Keep getting this error message when trying to load a cd of pictures from our newer MacMini onto an older MacBook.  Suggestions?

    What version of iPhoto on the Older MacBook?
    What version of iPhoto on the newer Mini?
    How did you make disk?
    Regards
    TD

  • PROBLEM LOADING PICTURES FROM DROID TO MY COMPUTER?

    The last few times I have tried to upload my pictures from my phone to my PC the application will not even come up or start...the phone goes to charge...I need to get these pictures off my phone! They are for work and I have quite a few of them on the phone? HELP?

    application?? use the included usb cable, select mass storage, open my computer/windows explorer.
    card will be the next letter after cd/dvd "motorola".
    find pics & drag to pc/mac folder.

Maybe you are looking for

  • Difference between Combo Box and Dropdown List

    Hi All, I would like to know the difference between the elements 'Combo box' and 'Dropdown List' in VC. I am facing an issue where i am invoking an entry list and the output of the first element the entry list returns is getting reflected as the outp

  • Need help msi 945pl neo crashed within 3 months use

    need help. my mobo doesnot start, no post, no beep.  1.main board 945pl neo(MS-7236) 2.video card: msi RX300HM TD128E 3.CPU Type: pentium 4 3Ghz (531) 4.Memory Type:512mb ddr2 533 kingston 5.Power Supply Type:generic 500W 6.Operating System:windows x

  • Iphone 5 error 3

    hi neither restore nor update 7.0.4. it's showing error 3 please help me

  • Missing Songs in iTunes Library

    My iPhone 4 has 662 songs in it, this being a mix of purchases and songs I have imported from CD's.  Somehow a problem has occurred with my laptop and my iTunes library has only 189 songs in it - all of these also being on my iPhone 4.  I last backed

  • R6025 Function Call "Please restart Audition" - solved

    Just thought I'd share my solution to this error: "To continue working where you left off, please restart Audition" R6025 Pure Function Call This started happening not long ago, as soon as I launched Audition. The error would pop up straight away and