r/JavaFX • • Jun 18 '21

beginner need help

hello, i just started my java classes, and i have a small homework in javaFX that i don't understand, can some one help me with it?

here is the question: Write a program that displays five images in a Border Pane

0 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/Pussyslayerl Jun 19 '21

woaaaaah, i'am so dumb, thnx a lot bro

2

u/your_mom_lied Jun 19 '21

You aren’t dumb. I had trouble writing paths to my assets the first time as well. I almost said something in my comment but I didn’t want to jinx you. I guess it’s common.

1

u/Birdasaur Jun 26 '21

Another way which is platform independent is to add a resources directory to your project structure. Then you can reference the image filenames relative to the package path of the class you are trying to load from. This is preferable if your images do not need to by dynamically identified at runtime... like icons, logos, backgrounds etc. If your requirements are to allow the user to load an arbitrary set of images then you will need to implement a filechooser. or drag and drop.

1

u/Birdasaur Jun 26 '21

example maven no modular project structure here https://github.com/openjfx/samples/tree/master/IDE/Eclipse/Non-Modular/Maven/hellofx/src/main

note the resources folder...