0

So, as the title pretty much says, my application works just like it should in eclipse, but when I export my application, the gui just shows a blank screen. I know it has to do with the pictures since when I use the program (it's tic tac toe), it still works like it should. Continuing, I understand that the problem has to do with how I load in the images. Here's an example: background.setIcon(new ImageIcon("src\board.png")); Is the file path insufficiently defined for it to be found when exported? There's no errors, which is good, but it doesn't help either. Any help would be appreciated.

3
  • 2
    Put the images in the jar and use a getResource method to read them. Do a search for full code examples.
    – NormR
    Nov 26, 2013 at 21:37
  • Thanks! I know it's probably a silly question to ask, but I'm just learning guis, so this really helped out.
    – mardiff
    Nov 26, 2013 at 21:48
  • Two things, 1- "src" is not likely to be available at runtime, so you should never use it ask part of your path. 2- ImageIcon(String) expects a File reference, but it appears as you are trying to embed the image within the application. If you are using eclipse, these should be stored in the "resources" folder and (regardless of the IDE), accessed using something like getClass().getResource(String) Nov 26, 2013 at 22:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.