How can I create dynamic events for a group/list?

Hey,.
ATM I'm programming request a bit where I add items to my center pane.

Simpyfied I got:

-Center pane: here are the items that appear on right click in the lower pane. This component must serve something like a playground where you can drag and drop and associate items in the bottom pane
-Low component: here, I got approximately 180 items which are quite equal. It's smth like a menu of items that you can use. I realized the java classes extended from a parent with v.f. dispute class.

What I want:
I want to create an event handler for EACH of the items 'menu' dynamically. Just sth like:
    for (int i = 0; i < basic_menu_list.size(); i++)
    {
      final Element el = hbox_bottom.getChildren().get(i);
      hbox_bottom.getChildren().get(i).setOnMouseClicked(new EventHandler<MouseEvent>()
      {

        public void handle(MouseEvent event)
        {
          if (event.isSecondaryButtonDown())
          {
            playground.add(el);
            redrawPlayground();
          }
        }

      });
    }
But as I expected, it does not work...

Now my question:
How can I solve this problem? Y at - it no option to listen to all the elements of a group without hard-coding every single listener?

Thanks for your help,
Martin

Hello user,.

Why you expected you it wouldn't work?
You have an example with the 'transition' apply on a bunch of circles in the Getting Started with JavaFx (http://download.oracle.com/javafx/2.0/get_started/jfxpub-get_started.htm)

Here is a class of the basic example...

import javafx.application.Application;

import javafx.event.EventHandler;

import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.TextBox;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;

import javafx.stage.Stage;

public class HelloWorld extends Application {

    //~ ----------------------------------------------------------------------------------------------------------------
    //~ Methods
    //~ ----------------------------------------------------------------------------------------------------------------

    public static void main(String[] args) {
        // Entry point
        Application.launch(args);
    }

    @Override
    public void start(Stage mainStage) throws Exception {

        Pane pane = new Pane();
        Scene scene = new Scene(pane, 200, 200);

        VBox vBox = new VBox();
        TextBox input1 = new TextBox();
        TextBox input2 = new TextBox();
        vBox.getChildren().addAll(input1, input2);

        for (Node input : vBox.getChildren()) {
            input.setOnMouseClicked(new EventHandler() {
                    public void handle(MouseEvent event) {
                        System.out.println("test click");
                    }
                });
        }

        pane.getChildren().add(vBox);
        mainStage.setScene(scene);
        mainStage.setVisible(true);
    }
}

Niculaiu

Tags: Java

Similar Questions

  • I have problems of space on my iPhone 6. I have only 21 photos and 2 videos on my phone. However, I am on a discussion group on whatsapp. How can I create more space for my phone? I also have very few applications on my phone.

    I have problems of space on my iPhone 6, I have only 21 photos and 2 videos on my phone. However, I am part of a chart group on whatsapp. The problem now is that my storage space is almost full. How can I create more space for photos and everything?

    You cannot create more space for everything.  All you can do is remove apps, photos and especially videos to make room for other pictures and videos.

  • How can I create a bootable for XP home CD

    How can I create a bootable for XP home CD?

    If by chance you reinstall xp sp2 via cd, you can create a bootable cd of xp sp3 via a method called "slipstreaming".

    It is relatively easy and requires files sp2 from your cd to merge with the update to sp3 from microsoft, and then make an iso to burn it to a cd.

  • How can I create extensible components for re-use?

    How can I create a button that stretches (such as the scale-9) with the text label? I create all of my graphics in illustrator rather than photoshop to get real FXG markup instead of embed all images?

    This has been addressed in the FAQ.

    Please see if the discussion he answer your question.

    -Bear

  • How can I create an event listener for the change of variable shared or similar?

    Hello

    I have a 'big' 6 devices communicating measurement system via the TCP protocol. The system is designed to use REST (the representative State transfer) with JSON (JavaScript object notation).

    Now, I need to add labview program to this environment. I've implemented a solution to 'work' with the help of this forum. Thank you for this! Now, I need to do better (currently no timestamps, large delays, etc.).

    I currently have a web service deployed using http-get as input. My web service .vi is just passing the web entrance to shared variables that are then questioned in real measurement program. Reason is that when I put the measurement program directly to the web service, it does not (something about rights and dependencies). Measurement program includes one third of the owners (Instron) drivers. Also I would not direct access via the network to our mechanical testing device potentially dangerous.

    Now, I want to change the message from the web services .vi commensurate .vi. Currently I have a loop of 10ms to query for changes in the shared variable. Is there a better way to do this? I thought create a listener to the shared variable change events.

    In addition, if you have any ideas (preferably, working code example) how to make the interface between labview and TCP-JSON I would really appreciate it.

    BR,

    Juha

    Currently in LabVIEW, the only way to create an event listener or event NSV is to use the DSC toolkit.  Most of the time the DSC is a very expensive tool that simply encapsulates the functionality that is built into the motor of the PSP and OAS and which is accessible to anyone who can program in LabWindows/CVI.

    http://zone.NI.com/reference/en-XX/help/370051P-01/CVI/libref/cvicnvcreatesubscriber/

    If you want to collaborate, I would like to create a small library of LV that would create a base SV events using a vi LV reminder or possibly passing return user LV event which is how works the DSC toolkit.  I asked OR several times to explain how do this and they're very tight discreet about it.  I guess that they do not want to give users LV less reason to buy the DSC.

  • How can I create a shortcut for the recycling bin in my office?

    Original title: Recycle bin shortcut.

    Anyone know how I can create a shortcut for the recycling bin in my office context menu (context menu)?

    Sorry Manu B G, but I think I understand what he wants exactly. This isn't a desktop shortcut but a shortcut context Menu. He wants a right-click on any empty space in the office and click Recycler Bin shortcut in the menu to go to the basket. Any way to do it?

  • How can I create friendly URLS for my meetings?

    I run an online meeting using Adobe connect and want to create a friendly URL for example: companyname.adobeconnect.com/meetingtitle instead of all the numbers and letters! How can I do this? Is this possible?

    The option for the custom URL is available in the first stage of the meeting Wizard (Variant 2). Once the meeting room is created the URL CANNOT be change, and a new room must be created to have a different URL.

    For example, to create a new room and give him the desired URL extension!

  • How can I create a tree for a flex definition tab?

    I have several tabs in my content tree and I want to show the user specific tabs to specific roles.

    The problem is, for example, the active product is the cell subtype and sub-type tablets and I want to create a tab to display a few cell phones to a user with the role A and I want to create a tab to display a few tablets to a user with the role of B.

    Thank you for your help.

    I ve found I can only create treetabs for parents to flex and not definition of flex.

    Solved my problem

  • How can I create a menu for a site to scroll a page for mobile devices?

    Hi, Im trying to create a menu for my version of phone of my a roll site page. I created a nice menu with the help of the Accordion widget, which when opened gives you links to different sections of the site that are defined by anchor points. The problem is when you select an element of the Accordion widget menu, it will automatically close after a click on the menu item. The site scrolls behind the menu, but you'll need to physcially close the menu by clicking on it again. It is of course a very bad user experience. I tried various menus third parties none of which work for sites of a page. Given the many Web sites is a scrolling page sites seems to be a major problem for users of Muse who have no menu option for this kind of design! Anyone know of any code that could be used to automatically close the Accordion widget when you select an item in the menu? Please help Ive spent a lot of time designing this site for the office but now having to PAP I can't produce the version phone, I really don't want to have to resort again to Wordpress.

    Thanks in advance!

    Hello! Active States help the user to see that they are on a separate page, and they can click the close button.

    Or you can see what I've done on the mobile page for one of my models that is very UI/UX friendly partially because of this reason (http://flowz.ljdezignz.com/phone/).

  • How can I create a redirect for a mobile site

    I want to get some opinions on this. I want to be able to when someone with a smart phone lands on the site, they have the possibility to view the full site or mobile.

    What is an advanced function? Is JS involved? I can easily do that in Muse or whatever I need to set up on a server?

    Thank you.

    Hello

    You can create a page for the site having options to access the mobile site or office.

    Then create links to the homepages of the desktop version and mobile on this page. You can create links through the hyperlink section.

    Also, you should uncheck "Redirect Office" on the file--> Site properties for the layout of the phone so that if the site is open on the mobile device, it shows only the first page office and not available phone directly.

    Kind regards

    Neha

  • How can I create legends customized for each image (large) target displayed with the widget to the Gallery?

    Greetings!

    I'm having any joy with the thumbnails Gallery - with the exception of a customization widget, I would like to make.

    I would like to have descriptive legends custom unique each 'target' (large image) image displayed. I can see the legend box personalized, move, modify, etc, but this is fixed for all images in the gallery.

    How do I change each caption for each image of the target?

    Thank you very much

    JL

    Assuming you are talking "Vignettes" under "Slide shows" widget in the widget library, simply drag the widget on a page to insert it. Once inserted, make sure you have legends in reverse by clicking the widget inserted on the page, and then on the small blue arrow top right of the widget that appears once the widget itself is selected, and check the box called "Legends", this will add captions [Lorem Ipsum] to each photo, you can then at this point click or double-click the text "Lorem" on each photo and that you want it to be. I hope this helps.

  • How can I create multiple fronts for a single diagram?

    Hello

    I developed a VI with several controls and indicators that should run on computers with a screen from 800 x 600 to 1680 x 1050 resolutions. The problem I have is that the façade don't is not properly for this range of resolutions by checking the options in 'Properties of the VI' option. Is there a way to create multiple panels before in various sizes for my diagram and select the façade appropriate in accordance with the resolution of the screen programmatically?

    See the attached Zip file.

    I have two different facades.  Either one open and run it.  They call MainCode.vi that takes the references which is past and register for events.  From there on, he does all the work of the code that you would put in your façade .vi.

    In this way each façade can be arranged however you want for each screen resolution.

  • How can I create new partition for dual boot (Windows 7/Ubuntu)?

    My Z580 came with 4 primary partitions: the Windows boot partition; Windows OS & data (C drive); a "Lenovo" partition which seems to have the drivers and software pre-installed (drive D). and an OEM partition that is used for key recovery.

    I want to create a dual boot system, as if I had on my old laptop, so I guess I need to delete one of the existing partitions and create an extended partition. The best candidate seems to be the 'Lenovo' partition with the drivers and applications. Can I backup the data on this partition and transfer it to the C drive... or put it on a new logical partition?

    Alternatively, it would be preferable to save the OEM DVD recovery partition, and then delete and create a new extended partition? I guess that means abandon OKR, but I'd still be able to recover Windows of DVDs (?).

    I would appreciate anyone's help. I am far from being an expert or computer whizz, so if you can help, please keep it simple!

    In fact, you can get if you only change the size of the D: drive. I guess that your D: drive occupies about 25 GB. You can delete this partition and shrink the C: drive as 100 GB (or any size you like) and you can create a new D: drive. This way you can use OneKey Recovery and install the second OS on a larger partition and yet once again, I suggest you create Factory Default disc before you do all this

  • How can I create an object for the vista HP 64 bit operating system installation disc?

    My PC shows signs a failure and I want to save my 'operating system', so I can "reinstall it later." Everything I saw in the forums are just consider my manufacturer. My Builder can not handle make me backups. I had to send them back 7 DOA (dead on arrival) and they never gave me a working copy. So in the end I just receive a refund. and geeksquad is way to expensive. so, how do I go about creating a disc of resettlement?

    Also the backup center and repair is more than the option to backup my operating system.

    Hello

    If you have a recovery disk partition hard HP are the people to contact about this

    It's their recovery partiton not microsofts

    and they have their own special way to make the recovery partition recovery disks

    If as you say your backup centers is not more work you can use 3rd party software to make a complete picture pc

    http://www.Acronis.com/homecomputing/products/TrueImage/

    or if you just want to reinstall a new copy of vista, read this:

    borrow a microsoft dvd vista

    Make sure that you borrow the correct 32-bit or 64-bit microsoft dvd to your computer

    they contain all versions of vista

    This is the product key that determines which version of vista is installed

    then get the hp vista drivers

  • How can I create a plugin for after effects 2015?

    My question is very generic, and I know that this could trigger a long discussion... I am in love with Video Copilot Plugins, and for many years, I followed the company in their fantastic products. If I wanted to create similar plugins, should what tools I use for programming? With what language they are written? And for the chart of the interface on AE?

    Greetings

    Leandro

    Leandro salvation! Welcome to the forum!

    the EI sdk is in c. you can work with the language you want, but

    Finally, the AE API calls will be in C/C++.

    the SDK comes with visual studio for windows and xcode project for

    Mac.

    effect controls window and comp window graphic overlay is created using

    subsequently drawbot provided by the SDK of EI.

Maybe you are looking for

  • Problem loading Lenovo MIIX 3 830

    Hello, I have a problem with my tablet to charge. When I turned on the shelf there is no sense the charger and do not charge. If I turn off the device the charging light flashes. I use the charger of the factory. If I change the problem is the same.

  • Drivers missing Port Serial PCI and PCI Simple Communications Controller

    I have an old Office Thinkcentre. It is a model 9196 and I am running Windows 7 (64 (b), and I get an error for my Serial Port PCI have not installed the drivers. I did a lot of research and found links to drivers in this forum, but they are every ye

  • Acer S3-391: FN F3 does not not on windows 10

    Acer S3-391: FN F3 does not not on windows 10 just received my unit refurbished and improved Windows 8.1 to windows 10. everything seems to work great except the F3 FN keys which is for wi - fi.  I don't really need since I can access it from the tas

  • My Window Media Player won't play WMA files

    Hi, only come to find out that my Player Windows Media won't play WMA files - they used to!  She still plays MP3 files, so his works, and it will play WMA files through my Denon AV receiver when I send them this Windows Media Player for her.  And whe

  • How to make part of the Simulator File Explorer?

    Hi all I followed this example http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=5295&query.id=354... to add a file from my application Explorer menu item. My problem is that there is no file Explorer I can say on my