2 Replies Latest reply: Mar 14, 2013 3:10 PM by 990211 RSS

    Is there any way to know the element clicked on a FlowPane?

    990211
      currently i have something like this:
      public class CtrlHand extends FlowPane implements Initializable{
           private ObservableList<Card> h;
      
           public void setHand(ObservableList<Card> h) throws Exception{
                this.h = h;
                renderHand();
                this.h.addListener(new ListChangeListener<District>(){
                     @Override public void onChanged(Change<? extends District> arg0){
                          Platform.runLater(new Runnable() {
                               @Override public void run() {
                                    try{
                                         renderHand();
                                    }catch (Exception e){}
                               }
                          });
                     }
                });
           }
      
           private void renderHand() throws Exception{
                this.getChildren().clear();
                for (Card c : h) {
                     CtrlCard controller = new CtrlCard();
                     controller.setCard(getClass().getResource(c));
                     CtrlGameHand.this.getChildren().add(controller);
                }
           }
      }
      public class CtrlCard extends StackPane implements Initializable{
           @FXML protected ImageView card;
           public void setCard(Card c){
                this.card.setImage(new Image(getClass().getResource(".."+c.getUrl()).toString()));
           }
      }
      is there any way to make CtrlHand know wich card(CtrlCard) have been clicked? if so, how?