The key fire method does not work

Hi all

I have a little problem with my javafx application. I designed my application with the scene designer and added a few buttons for them. For each button, I defined a listener method (annotated with @FXML) and

I also added each button as member variable to my controller. So far so good.

Now my controller extends an AbstractController which has certain functions inside. Inside of my method to initialize I pass the button to a method of the abstract class to collect the buttons inside a set.

Now, to a point that I want to get all buttons of my abstract class defined but that does not work.

I tried to add to each button setAction method and implemented an anonymous class before you put the button in my game. Then the fire of the button method calls the anoymous class / method. But

Why it works don't not with a @FXML annotated method?

The problem would be the "timing"? If I switch the button the the class abstract in the init, the button may not be registred listener method? Just for my understanding, when the init method calls anyway?

It is difficult to create a small test application for this problem, but maybe someone can help me already.

Greetings,

Hauke

I misunderstood the question a bit, I think. It also works with the following changes:

Buttons.fxml







 

Controller.Java

import javafx.event.*;
import javafx.fxml.FXML;
import javafx.scene.control.Button;

public class Controller extends AbstractController {
  @FXML private Button button1;
  @FXML private Button button2;
  @FXML private Button button3;

  public void initialize() {
  this.addButtons(button1, button2, button3);
  }

  @FXML private void buttonPressed(ActionEvent event) {
  Button button = (Button)event.getSource();
  System.out.println(button.getText() + " fired");
  }
}

In this version, where managers of the action for the individual buttons are defined in the FXML, these action handlers will be actually installed earlier: before Controller.initialize () is called (and potentially before the controller is instantiated and the buttons are injected in the it).

Tags: Java

Similar Questions

  • The Stream.play () method does not work why?

    I want to create an application to switch streams and republish them under continuous flow unique to the remote server.

    In the first step, I tested "Livestream code" of the "Multipoint publishing example" p. 184 of "FLASHMEDIA SERVER 4.5 Developer's Guide ADOBE®" If ns.publish method is used. He managed.

    I try stream.play method now.

    I wrote main.asc code as in the Stream.play example (p. 162) of the 'the ACTIONSCRIPT Language Reference® to ADOBE® FLASH® MEDIASERVER 4.5 server-side", but I have a certain problem despite this.

    I try to spread on my local server (Uri - "localhost/studia") by two customers - OUT and my request for "Livestream" accordingly (with stream name "livestream2") and retraslate it to a remote server by using my "studia" on a local application.

    The connection between two servers (with application "on-line") appears in the Remote Server Admin Consol, but the flow of my local server do not come to her.

    Here's my main.asc script:

    application.myRemoteConn = new NetConnection();

    application.myRemoteConn.onStatus = {function (info)}

    trace ("Connect" + info.code + "\n");

    Respond to all customers

    for (var i = 0; i < application.clients.length; i ++) {}

    application.clients [i]. Call ("onServerStatus", null, info.code, info.description);

    }

    };

    Connect use NetConnection object remote server (the remote server works with other application wery well)

    application.myRemoteConn.connect ("rtmp://RemoteServer/live");

    Estimate of the server data flow

    application.myStream = Stream.get ("livestream");

    application.myStream = Stream.get ("livestream");

    If {(application.myStream)

    application.myStream.play ("livestream2", 0, -1, true, application.myRemoteConn);

    }

    The Stream.play () method does not work why?

    What I've done wrong?

    In this case, I recommend a mixture of solution...

    Something like that will be interesting to check:

    var tempSwitchingStream = Stream.get ("myswitchingstream"); create a stream live temp on the server local app...

    tempSwitchingStream.play (livestream1, 0, -1);      Subscribe to tempSwitching to livestream1... That is to say get the content of livestream1 in there... I can also switch to different streams inside... tempSwitchingStream will get the contents of the stream of //switched

    If (tempSwitchingStream) / / if there is

    {

    NS. Attach (tempSwitchingStream);  Subscribe to my net workflow to receive data from tempSwitchingStream

    NS. Publish (livestream, "live");  now flows net is get data from tempSwitchingStream, so publishing those data with the name "livestream" on the connection to the network... NET already know its NetConnection... See above

    }

    Did you get the point? I created a temporary stream that can pass the stream in its method of game and then I push this temporary stream to a remote server...

    However, it is tricky... Majorly, in most cases similar to yours, people write applications on the application of remote server to get the stream and he spend the pull in play method as described in the first method discussed...

  • Why the camera StatusEvent method does not work in Flex 4.6 Desktop Application?

    Hello

    I have a simple Desktop Application (in collaboration with adobe AIR) that retrieves the web camera, adds two EventListener (activity and event status) and starts the preview.

    The event activity method works correctly while the status event method to notify that the correct connection is never thrown.

    Here is the method to initialize and start the webcam.

    private function videoDisplay_creationComplete():void 
    {
              camera = Camera.getCamera();
              camera.setMode(320,240,15,false);
              camera.setKeyFrameInterval (4);
              camera.setQuality (0,100);
    
    
              videoDisplay.attachCamera(camera);
    
    
              if (camera) 
              {
                        camera.addEventListener(ActivityEvent.ACTIVITY, camera_activity);
                        camera.addEventListener(StatusEvent.STATUS, camera_status);
              } 
              else 
                        textArea.text += "Nessuna camera disponibile.";
    }
    
    //Listener chiamato quando il video o il microfono vengono attivati/disattivati
    private function camera_activity(evt:ActivityEvent):void 
    {
              var str:String = "[{0}] activating:{1}\n";
    
              textArea.text += StringUtil.substitute(str,
                        evt.type,
                        evt.activating);
    }
    
    
    //Listener chiamato quando lo stato della webcam cambia
    private function camera_status(evt:StatusEvent):void 
    {
              var str:String = "[{0}] code:'{1}', level:'{2}'\n";
    
              textArea.text += StringUtil.substitute(str,
                        evt.type,
                        evt.code,
                        evt.level);
    
              switch (evt.code) 
              {
                        case "Camera.Muted":
                                  Alert.show("User denied access to camera.");
                                  break;
                        case "Camera.Unmuted":
                                  Alert.show("User allowed access to camera.");
                                  break;
              }
    }
    
    
    

    Thanks in advance.

    Greetings

    I think that if you already allowed access to the camera (for example the Flah Player asks you anymomre to allow) you wil get event direct activity instead of the status event.

    The status event is absolutely necessary if you get the triggering event. You can check current FPS the camera and if is > 0 for an interval of shor your camera works very well.

    C

  • Drag and drop the game. splice method does not work on the table

    Hello

    I have a drag and drop game. You listen a sound for 'bread' peculiarities, you switch to slide that mc in a box. If it's the right object I want to delete as mc and splice table so it isn't select this object more.

    However I notice two things.

    When I splice (0) a specific item - so nothing works.

    When I connect the indexed element cuurent IE: the last element to get right - it is not actually delete it table.

    I highlighted the parts of key code.

    private function placeBubbles (): void
    {
    var nextX:int = 0;
    for each (var: bubble in bubbles)
    {
    bubble.buttonMode = bubble.useHandCursor = true;
    bubble.addEventListener (MouseEvent.MOUSE_DOWN, dragHandler);
    bubble.addEventListener (MouseEvent.MOUSE_UP, checkDrag);
    Bubble.x = 0 + nextX;
    Bubble.y = 300;
    nextX += 100;

    addChild (bubble);
    }
    nextGameRound();
    }

    private function nextGameRound (): void
    {
    currentIndexArray = int (Math.random () * bubbles.length);
    currentBubble bubbles = [currentIndexArray];

    currentBubble.playSound ();
    }

    private void checkDrag(e:MouseEvent)
    {
    e.currentTarget.stopDrag ();
    If (this.currentBubble.hitTestObject (this.box))
    {
    If (currentBubble & & currentBubble == e.currentTarget)
    {
    currentBubble.visible = false;
    trace ("Right");
    Bubbles.splice (currentIndexArray);
    Bubbles.splice (0);

    trace (Bubbles);
    nextGameRound();
    soundCorrect.play)
    }
    }
    on the other
    {

    TweenLite.to (e.currentTarget, 1, {x: xIni, y: yIni, ease:Strong.easeOut, onComplete:onFinishTween}) ;// - If you want something happens on the ending of tween - good idea while children must wait})

    }
    nextGameRound();
    }

    the splice() method accepts two arguments.  the first is the index of the item to delete (start) and the 2nd argument is the number of elements to remove.  in your situation, you should use:

    Bubbles.splice(currentIndexArray,1);

  • The date and time does not work.

    I have an iphone 5 c.

    The date and time does not work. This is the second time.  The first time was about 3 to 4 months again and now again after upgrade to iOs9.3.1.

    Even after trying to change it manually, time slows down or stops.

    Everyone has problems with their date and time?

    • Try a forced reboot: hold down the House and on the buttons until the unit turns off. Ignore the cursor off if it appears. Once completed, if it does not start on it own, turn off power with the key On. In some cases, it also contributes to double click the Home button and close all applications before restarting.
    • Restore factory settings (no backup)
    • Make an appointment at your local Apple store to have it checked.
  • calendar for the week of jQuery does not work in the new version of firefox v42.0

    Hello
    Thanks for your reply.
    IAM develop on the issue that iam facing knowledge, events on the calendar for the week of jquery does not work in firefox version iam 42.0 faced to the problem that iam unable to change back or delete nominations that are displayed.
    For example if try clicking on one of the appointment generally a popup comes to change or to restore or remove the appointment but iam not getting that. But this feature does not work in lower versions of firefox (version 32.0 for example). Please check the jquery week calendar demo following URL looks like this:
    http://robmonie.github.IO/jQuery-week-calendar/full_demo/weekcalendar_full_demo.html

    I've just rescheduled lunch 12:00-12:15, so it seems to work on 42 Firefox on Windows.

    What is the latest version, where it has worked for you?

    Have you tested Mode Firefox safe to rule out the possibility of an extension conflict? See: Firefox in Safe Mode troubleshooting questions.

  • Bought two of the iTouch, one for my wife and one for me. In the Notes his has the "" symbol for the formatting and mine does not work. Any suggestions?

    I bought the iTouch two at a time, one for my wife and one for me. In the application 'Notes' my wife shows the symbol "+" to the formatting and mine does not work. Any suggestion.

    Could you please include screenshots of the so-called issue?

  • the software sticky password does not work.

    the Sticky Password plugin does not work in Firefox 37.

    Changed the product forum this thread is in Thunderbird in Firefox so no need to create a duplicate thread.

    It is an Extension in Firefox and not a Plugin like Flash or Java.

    You're too test is based on the Beta channel (currently at 37.0b3), and the Extensions like these tends to do not support the current version at most which is Firefox 36. www.mozilla.org/Firefox/All/

    In the Sticky Password software you can go in "parameters - supported browsers and install the extension" because I think that may be the case there are updates? https://support.Mozilla.org/en-us/questions/948577

  • Firefox does not (Cup) of the lower edge and the right edge of the graph. IE10 does not work.

    Firefox does not (Cup) of the lower edge and the right edge of the graph. IE10 does not work.
    Office Windows 7 2009 service pack 1 Firefox 26 Internet Explorer 10
    Flash player version 11.9.900.170 plugin 11.9.900.170 activex version used by Firefox

    Problem began late November when Miniclip.com forced updated flash player to version above
    -C' was when they started to play a video advertising in the game box before you could start.

    Have screen shots of IE10 and Firefox26 side-by-side clearly showing the problem - how these can be downloaded for see you? E-mail? Web site? This place seems to be text only?

    In the meanwhile the grandchildren and self have learned to use IE10 instead of Firefox that we prefer.
    Their House of Windows XP has same Flash Player in Firefox and it works fine.

    Downloaded two screenshots on Media Gallery.

    You can not attach a screenshot in the first row who starts a thread, but you can do it in subsequent responses.

    Try disabling hardware acceleration in Firefox (you will need to close and restart Firefox).

    • Tools > Options > advanced > General > Browsing: "use hardware acceleration when available.

    See also:

    Reset the zoom of page on pages that are causing problems.

    • View > Zoom > reset (Ctrl + 0 (zero); 0 + Command on Mac)
  • Ejection of the Replicator Express - II does not work

    The duplicator button eject does not work. I have laptop series TECRA M. downloaded the driver for duplicator of toshiba website support and reinstalled but of no use. I searched in all the forums, but did not find any thread for this problem.

    If anyone has any idea on this issue, please help. The button eject everything does and do not see an option in Windows 7 to eject the PC I did with IBM lenovo laptop with a docking station.

    Is - this top hat of Toshiba laptop what do you use?
    I want to say I put t knowledge how it works on other laptops but why you think it should work in the same way on laptop, you used before?

    You can remove your Tecra of docking station using gear hand placed on the upper side right?
    What happens after doing this?

    By the way: If you check the specs of this under system requirements port replicator s Win7 are not.

  • I keep seeing pop up ads powered by '' cn tatami '' whenever I have to navigate using Safari or open a link on the FB Adblocker app does not work for this. Any suggestions? There is no option to cross the pop-up ad that it redirects to various Web sites.

    I keep seeing pop up ads powered by '' cn tatami '' whenever I have to navigate using Safari or open a link on the FB Adblocker app does not work for this. Any suggestions? There is no option to cross the pop-up ad that it redirects to various Web sites.

    Cache and history of the site Clear settings - Safari -.

    (1232)

  • Why the Polish support page does not work?

    Why the Polish support page does not work?

    http://PL.consumer.Toshiba.EU/PL/support/home/support_home?

    I think the error message is pretty clear:

    + Service temporarily unavailable +.
    + The server is temporarily unable to process your request due to downtime or maintenance capacity problems. Please try again later. +

  • How can I get the airplay icon to appear? Changing the settings of firewall does not work

    How can I get the airplay icon to appear? Changing the settings of firewall does not work

    Hello Drjoe378,

    I understand that you do not see the AirPlay icon in iTunes on your Mac. If you have verified that your firewall is disabled or that the problem occurs regardless of the status of your firewall, there is a little more that can help return your ability to connect to AirPlay devices.

    1. Make sure you have the latest version of iTunes and Apple TV software.
    2. Connect your computer and other devices on the same network Wi - Fi. If you are using Ethernet, connect the two devices on the same router or hub. If you use the Wi - Fi and Ethernet, plug your device AirPlay the same router that your computer uses for Wi - Fi.
    3. Restart your computer, device AirPlay and network router.
    4. Because some Airplay devices include a power switch for AirPlay option, look for the option in the settings and make sure that the feature is enabled. Refer to the user guide of the device for more information.

    Use AirPlay to stream content from iTunes on your computer wireless
    https://support.Apple.com/en-us/HT202809

    All my best.

  • Microsoft Security Essentials - the planned-out scan does not work.

    In addition to the question about the scheduled scan output after upgrade to Windows 7 to McAfee.Microsoft Security Essentials series instead of McAfee. The scan-out plan does not work.

    Support McAfee tried to straighten my computer of conversation I understood the problem of the update disc. I want to ask a question to the update command:? many problems were very pushed us all after your update. How now to get out of this dung under the name Toshiba upgrades?

    Hey Buddy,

    To be honest I don t know what you re talking about exactly. What has to do with Microsoft Security Essentials McAfee?

    As far as I know it s recommended using a security program only. You must use a Microsoft or McAfee, but not both!

  • Webcam on the Satellite A200-175 does not work - error code 10

    Hi all

    I bought a Satellite A200-175 yesterday and I am trying to use the webcam, but it does not work. I searched the forum for possible solutions, but so far I have not found anything that solves my situation.
    The laptop came with a preinstalled Vista OS, but the software of the webcam was not preinstalled. So I downloaded the latest Toshiba download page doftware and installed.
    Subsequently, it still does not work and so I changed drivers for generic Microsoft (based on the advice of the forum).

    I tried to reinstall drivers (several times), but that did not help. Device Manager keeps giving me the error code 10 (device cannot be started).

    I'm a bit of idea, so any help would be appreciated!

    Hello Franca

    It's very strange because I installed the recovery image on notebooks P200 and U300 (both with the webcam) and I didn't notice any problem. After the first boot the cam will be recognized as new hardware and installed correctly.

    Have you installed some Messenger like Yahoo or MSN and try to use it with one of them?

Maybe you are looking for

  • Ideas to create Android as widgets on the home screen in Blackberry

    Hi all I need to create and place a widget on the home screen. Please suggest/share ideas for the creation of Android as widgets on the home screen of Blackberry. Is this possible in Blackberry? Help, please. Thanks in advance.

  • Page transition animations

    Is there anything in order to implement the transition page such as flipping, twirling animations, sliding to the bottom to the top, etc. ? I see that it is possible to attach animations to transition to UI controls, but don't see any way to do it fo

  • Click on MenuItem and consume

    is it possible to consume a click from a menu item? I use ListField to view the records that can be edited by clicking on a particular record, which displays an edit form. The problem arises when I want to extract fresh data from a webservice and red

  • Can I install IIS server in windows 7 Home Basic Edition?

    Hello I followed the steps below to install the IIS server in Windows 7 homw base. Start-> Control Panel-> turn on OR off windows features Because I chose this IIS services, and then I clicked Ok. After that, I checked in drive C... in this issue of

  • Where is photosmart essentials

    I've recently updated my scanjet scanner 4050 and now don't do not have no photo editing - first software photosmart (essentials) this is what I used to have b4 upgrade.  How can I get the return of photo editing process?  I am running windows 7. Tha