Is it possible to know the item clicked on a FlowPane?

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 CtrlHand know card (CtrlCard) which was clicked? If so, how?

Just register a listener for mouse with each card...

for (Card c : h) {
  final CtrlCard controller = new CtrlCard();
  controller.setOnMouseClicked(new EventHandler() {
    @Override
    pubic void handle(MouseEvent event) {
      System.out.println(controller +" was clicked");
    }
  });
  controller.setCard(getClass().getResource(c));
  CtrlGameHand.this.getChildren().add(controller);
}

Tags: Java

Similar Questions

  • Is it possible to customize the right-click menu?

    I use FF4 RC2 and I wonder if it is possible to customize the context menu? In FF3 if you right click on a tab lists ' new tab '. Reload tab reload all tabs... "etc. but in FF4 if you right click on a tab lists only "Reload Tab | PIN as App Tab... "etc.

    I really really use the right click-> new tab in FF3 A LOT! It was a HUGE disappointment for me when I started using FF4. Is there anyway that I could add the button tab in the right click menu?

    Thanks in advance!

    Not that I know of. You can use file > new tab or Firefox > tab in addition to what I posted above.

    Maybe an extension like Tab Mix Plus can add this feature in the context menu of the Tab bar.

  • Is it possible to cross the items in reminder similar to what you would do for a list of the written tasks?

    I want to use the text "off" option to cross the items on my reminder similar to what I would do with a written reminder.  In this way, I know what items I have completed as well as article I have left to do.  Is it possible to do this by using Sticky Notes?  I seem to be finding more reasons to not use this tool (cannot easily change fonts and now this...).

    I found it.  Highlight the text and use CTRL-T.

  • focus on the item clicked - GUI

    Hello

    I have a form that the user will fill out which has many controls for string and enum, over 40.

    Wil user tab and fill out one by one. I want to set focus on the control when the user clicks on it.

    I don't want to do more than 40 cases of events and each control separately.

    My another idea is to get refs and the positions of all the controls in the FP, then monitor mouse click event on PS, get the guts and find this control.

    But maybe there's a more elegant way that I don't know?

    Hey Pawhan11,

    You can place all references in a table and join a mouse down event. In an eventstructure use the dynamic event for the enum modifyy, you clicked.

    Kind regards

    CMW

  • Is it possible to disable the "long click" "Prompt to download" mini menu WebWorks?

    Hello

    Although the feature click-n-hold to bring up the menu mini BlackBerry with the option to "Invite to download" is very convenient, in my application (at least in some areas) it is certainly not desirable.

    In my case, I got an arrow "spinner", that the user can click on increment, or click and hold to auto-increment at a speed faster they can click.

    It works by starting the auto-increment "onmousedown" and continues to run until "onmouseup" (e.g. user break)

    However, on the BlackBerry device... a click and waiting for a second about causes the mini menu popup (blocking the view) to and do not trigger the mouseup... event so the control turns uncontrolably.

    Mini menu:

    I wonder if there is a setting to turn this off on one for each item (for example, a special attribute) or the worst case... a way to completely disable the function in my application (not a huge problem, because it is an option in the menu of the main application to invite a user)

    I tried the blackberry.ui.menu.clearMenuItems (); https://bdsc.webapps.BlackBerry.com/HTML5/APIs/BlackBerry.UI.menu.html#.clearMenuItems and looks like it works fine ;-)

    Thanks for all your help!

  • Is it possible to know the service provider of the user to use in my blackberry application.

    Hi all

    I have a requirement in my applocation to know the user's service provider (such as Airtel, idea, DOCOMO,... etc.).

    Is it possible to get the service provider of the user in the blackberry app.

    Please help me with this...

    Thank you & best regards

    ---------------------------

    Ravikumar Chinatada

    See RadioInfo.getCurrentNetworkName ().

    Scott

  • Is it possible to know the date and time, when a form has been consulted last?

    Hello
    I use forms 6i. Is it possible to know what form was last accessed by any user?

    Concerning

    Only if you implement such a feature. (Perhaps written at a table in the PRE-FORMS-relaxation in a standalone transaction)

  • Is it possible to know the event of scrolling down

    I'm doing a function to automatically load the data if ListView is already scrolled down so that I want to get this trigger. But I don't have the solution. Does anyone know the idea or any sample? Thank you.

    This can help:

    http://developer.BlackBerry.com/Cascades/reference/bb__cascades__listscrollstatehandler.html#functio...

  • Is it possible to sort the items in a folder by Type, Date, etc is available in Windows XP

    I am trying to sort my photos by file type and name. This does not seem possible. Why would they not incorporate a feature available in XP that was very helpful?

    It works the same as XP.  Do it how you used to.  Put it in the Details view, and then click the file Type column to sort by there.  If you do not see the Type column, right-click a column header and select it.

    There is no difference in him and XP, it works exactly the same.
  • Is it possible to prevent the right click context menu of the combination of Stop/Reload?

    Is it possible (subject: config tweak or something) to prevent the context menu of the combination of Stop/Reload?

    Screenshot of what I mean: http://picsend.net/images/873089StupidReloadSto.png

    Try to add this code in the file userChrome.css below default @namespace.

    Customization files (interface) userChrome.css and userContent.css (Web sites) are located in the chrome folder in the user profile folder.

    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    
    #context-stop,#context-reload[hidden="true"] { display: -moz-box!important; }
  • is it possible to know the device password value or not?

    As the title,

    Is there an API to check if the user is set in password on or off?

    Thank you

    The f

    DeviceInfo.isPasswordEnabled)

  • Is it possible to know the file name of the loaded images?

    Hello:

    I have a folder containing images named 01_image_name.jpg, 02_image_name.jpg, 03_image_name.jpg,... names that I read with a PHP script. Then I wrap each image loading and wait for all are responsible to view

    1. the PHP script reads the names file and returns a string with names separated by a "|" char, then I use the split to store in imagesNames table method and sorting
    2. I loop table of imagesNames hollow loading images
    3. anytime a new image arrives I push imagesContainer table and check if all the images are loaded to show them

    The problem is that there is no guarantee that they arrive in the same order they opposed. So, how I sorts the array imagesContainer of file name, i.e. in the same order that they are imagesNames table?

    Thanks in advance

    function imgLoaded(par:Event):void {}

    trace ("the loaded image comes from this url:" + par.target.url);

    ...

    }

  • to choose the simple click instead of double click for selection using the mouse is no longer seen in Win 7 Pro

    possibility to choose the simple click instead of double click for selection using the mouse is not seen more in Win 7 Pro.

    where you can select the option, please? Thank you

    Hello

    You do not tell us where you are looking for it.

    "Click or double-click to open an item".

    http://www.SevenForums.com/tutorials/10117-single-click-double-click-Open-item.html

    See you soon.

  • Sort the items in the tree manually

    I am trying to allow the user a way to move through the items in a tree 2 levels deep. This will give the user the possibility to order the items within the tree, so they can be sent to the word in the desired order. I have working code to get through the items at the lowest level, but I can't that it works correctly for items in folder level. I have a code that works very well, but he has a little problem. I found that if you stay with moving a folder to the top of the tree then you do not experience the problem. However, if you switch to another folder to move then you will experience the problem earlier. The problem seems to be a copy of a part of the tree and add at the end. I don't know, what's happening! I was hoping that someone could help me with that.

    Does anyone know a way to do this? Oh yes and I wish that property selectedIndex to stay with the folder selected as well.

    Thanks for your help.

    It can be done, Sephiroth did a drag ' n drop component
    to sort items in a component of the tree.
    http://www.sephiroth.it/file_detail.php?ID=133

  • How to know the host name using IP SCAN

    Hello

    It is possible to know the hostname from / IP address using the IP configured SCAN?

    Please do not give me the links for - what is SCAN IP and how it works... Please

    Just trying to find out whether it is possible or not.

    Thanks in advance.

    Kind regards

    Mukesh

    Hello

    > Is it possible to know the hostname from / IP address using the IP configured SCAN

    What hostname... database hostname name clustered...? If so you can not, because the IP SCAN is not assigned to any host, SCAN name is defined in DNS that resolves the 3 IPs in the method of Robin, hope this clarified your question.

Maybe you are looking for

  • Problem with sound on my A60 302

    When I turned on my laptop A60 - 302, some times its not connect. I use Windows XP Pro SP1.This problem of sound is verry confuse a few times when I want to watch movies to play music.My E-mail is [email protected]

  • T43 RAM will go in a T42?

    Anyone know? I want to upgrade my ram to 2 GB, need to know if T42 and T43 using the same memory modules live, or is there a difference please? AHA

  • Agilent 66 x pilot IVI/VXI series

    Hello! I used to communicate smoothly with Agilent 66 x series of power supplies in Visual c# .NET, after wrapping his file of .fp VXI/PNP with .NET wrapper Wizard. I have been using an old installation file of driver 661x.exe which included everythi

  • I can't stop my personal folders in shared with comments

    Gentlemen.Some time ago, I consulted my personnel file (which is C:\Users\) since the guest account. As expected, Windows prompts the administrator password, and I have provided the password. The problem is, the guest account now can always see and o

  • Windows firewall stops when a wireless connection is established.

    Windows firewall stops when a wireless connection is established during the start-up or wakup or manually connected via wireless.  The firewall can be activated manually after wireless connection is established.  Firewall survives boot and reactivati