getting corresponding filename of image once button pressed

后端 未结 4 1638
南笙
南笙 2021-01-28 19:20

A Set of imagefiles are added to an arraylist(filelist2) of type File.Then an imageview and a button are affffded to a vbox,such vboxes are added to a grids of a gripane using a

4条回答
  •  攒了一身酷
    2021-01-28 20:03

    Use setUserData and getUserData to store and retrieve custom values in Nodes ! Set the fileName as the userdata and on click, retrieve it.

    downloadbtn.setUserData(filelist2.get(index).getName());
    downloadbtn.setOnAction(new EventHandler() {
         @Override
         public void handle(ActionEvent arg0) {
                System.out.println(downloadbtn.getUserData());   
         } 
    

提交回复
热议问题