我有这样的项目结构:
并尝试使用此代码
创建带图像的LabelbAddTheme = new Label("Add theme",
new ImageView(new Image("images/addTheme.png")));
编译后得到错误,如"无效的网址:找不到无效的网址或资源"。如何正确写入文件路径?
答案 0 :(得分:0)
试试这个:
bAddTheme = new Label("Add theme",
new Image(getClass().getClassLoader().getResource("addTheme/sif.png").toExternalForm()));
答案 1 :(得分:0)
@aribeiro如何说我把它当作:
new Image("com/GVArt/images/addTheme.png"). Try looking at your folder structure outside of your IDE in order to understand it clearly.