2

My image doesn't want to be loaded, I don't know if it's the path, image format or error in the code. I have tried to detect what the problem is by different ways.

Here is the error code.

enter image description here

My workspace is located at

https://s32.postimg.org/reakyw3qt/image.png

This folder contains two additional folders, "bin" and "src". I have tried relocating my image to different subfolders just to be sure.

enter image description here

But still won't work, unfortunately. After having read the questions here on the site, there was a suggestion to check the path with these two short codes.

enter image description here

(tried also with texAccount.png)

The first command was successful, giving me the following line.

enter image description here

And then I became confused. It wants to load files from the "bin" subfolder, however my Scanner opens, reads, writes all the files into the root folder. I do not have my text files in the "bin" subfolder but the root folder and works perfectly. Maybe it just loads from the very first folder in my root folder? I created a subfolder named "asd" just to check it: No, I was wrong. The program definitely wants to load my image from the "bin" folder, giving me the same message as above.

I spammed all the folders with my picture. Okay, so my image is in the right folder after all. I thought I would check my code rather.

enter image description here

I tried to change the "texAccount.png" in code to just "texAccount", still would not load. Then I renamed my actual image file to "texAccount" and "texAccount.png", however I combined the names it showed no progress. My image is only 20x20 in size, but contains alpha channel. As I am a beginner, I do not know, maybe alpha images must be dealt in some other ways, so to be sure I deleted my alpha channels and made a fully black picture, basically a 20x20 black box, no success.

I have tried converting my file to .jpg and three other formats. I have imported all the required classes and packs needed for working with images.

Thank you very much! ( I posted all my codes and quotes as pictures )

halfer
  • 19,824
  • 17
  • 99
  • 186
Hydraxia
  • 81
  • 2
  • 9
  • 2
    Please do not post the code and error messages as images; post it as text and [format](http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks) it. – James_D Jun 21 '16 at 19:57
  • 1
    You could take a look on [this](http://stackoverflow.com/questions/37359583/javafx-how-to-load-a-local-html-file-from-project-directory-in-webview/37364847#37364847) to figure out how could you load your image. – DVarga Jun 22 '16 at 05:31
  • Thank you very much DVarga, this really helped me to figure out paths and my image is loaded now. ( Sorry for the codes as pictures, the page said I had problems with formatting, next time I promise I'm going to fix that too, I apologize ) Have a great day! – Hydraxia Jun 22 '16 at 06:53
  • If this is solved, please add an answer below, rather than amending [solved] to the title - we prefer not to do that here. Thanks! – halfer Jun 26 '16 at 15:17
  • Also, James is quite right that we _require_ textual information to be provided as text, and if you receive a request to fix it up, please do even if the issue is solved. Ideally, we want to maintain questions here, so they are useful for future readers. – halfer Jun 26 '16 at 15:18

1 Answers1

2
Image image = new Image("texAccount.png");

Do not need to do other steps!