Where does javafx.scene.image.Image(“flower.png”) look for flower.png?

后端 未结 3 1511
长发绾君心
长发绾君心 2020-11-27 07:36

I would like to know what the JavaFX Image constructor\'s relative path resolution algorithm is for:

  1. Stand-alone apps.
  2. Browser deployed apps.
3条回答
  •  猫巷女王i
    2020-11-27 07:46

    1. search directory where class files( name of class getClass().getName().toString() ) related to your .java file are present, copy and paste your image there
    2. Image image=new Image(getClass().getResourceAsStream("yourImageName.jpg")); is must.

    In NetBeans the directory where classes are present NetBeansProjects/JavaFXProjectName/build/classes/packageName/

提交回复
热议问题