How to change scene graph from listener thread?

Greetings,
I need a little help with javafx.concurrency.Task - I think.
I have a JavaFX program that is listening for JMX Notifications. When I receive certain notifications, I want to change the scene graph. Of course, the notifications are being received on a thread kicked off by RMI, not the JavaFX Application thread -- so anything I try to do to the scene graph there won't work.
I've look at Richard Bair's article: http://fxexperience.com/2011/07/worker-threading-in-javafx-2-0/
and other examples, but every example I've found involves kicking off the Task from the Application thread and observing some property of the Task.
I think I somehow need by Notification listener to queue up the things that need to be done to the scene graph somewhere, and then have a thread started from the Application thread read the queue and actually make the changes.
I could use a pointer to an example, or even a general overview of how this type of thing should be accomplished. I could post a code example if needed, but it will take some doing and it wouldn't even be working.
Thanks,
Cameron

Tasks/Service are most useful when you are initiating the action via the GUI (i.e. as a result of a button press, a mouse event, a keyboard action, etc). In your case JMX/RMI will be running an internal 'listener' thread which is triggering your handler method. In this case the best option is to just use Platform.runLater.
Something like the following"
{code}
public void handleEventFromServer(final MyData dataFromServer)
Platform.runLater(new Runnable() {
public void run()
// this will be done in your GUI thread so you can update the GUI here
myTextField.setText("Result from server is: " + dataFromServer.getSomeValue());
{code}
If you have some sort of JmxListener interface you could just create a ThreadSafe event propagator like so:
{code}
public class ThreadSafeJmxListener implements JmxListener
private JmxListener actualListener;
public ThreadSafeJmxListener(JmxListener actualListener)
this.actualListener = actualListener;
@Override
public void handleJmxEvent(final JmxEvent event)
Platform.runLater(new Runnable() {
public void run()
actualListener.handleJmxEvent(event);
{code}
Then just use it something like so:
{code}
jmxChannel.addJmxListener(new ThreadSafeJmxListener(new JmxHandler()
public void handleJmxEvent(final JmxEvent event)
// this will be done in your GUI thread so you can update the GUI here
myTextField.setText("Result from server is: " + dataFromServer.getSomeValue());
{code}
If you want to send data to the server, use a task (or service) for that. If you need more info on that, post back, but there is a fair bit of that in this forum, or on various blogs (you'll find a fair few examples buried in my posts: http://zenjava.com).

Similar Messages

  • How to change my subscription from "CC single-app Photoshop" plan to "Photoshop Photography" plan

    How to change my subscription from "Creative Cloud single-app membership for Photoshop (one-year)" plan to "Photoshop Photography" plan after purchase already and overlap?

    I waiting Live Chat about 2 hours and my thread not any support help to me or feedback.
    Why!

  • How to change mobile network from At&t to verizon

    how to change mobile network from At&t to verizon

    What exactly are you trying to do?
    You can't "change the mobile network"?
    What device model number do you have?
    Has it worked previously?

  • How to change a photo from 32 bit mode to 16/8 bit mod in Photoshop cs6?

    How to change a photo from 32 bit mode to 16/8 bit mod in Photoshop cs6?
    I tried to go to Image- Mod but i cant press on Mod button..
    I saw to late that i cant save the image i created with 32bit mode.
    Please help..

    In the image menu, goto the mode sub menu, then choose 8 or 16 bit.

  • HT1311 how to change the payment from visa to none payment iPhone 4S

    how to change the payment from visa to none payment
    iPhone 4S

    martinimartini wrote:
    I have the same problem. I used Pay Pal payment before but Pay Pal limited my account so I can only use Pay Pal until after 180 days according to their specific regulations. I also do not have any credit card. How am I supposed to pay for my Skype that I have been using since start of Skype. I really need outgoing calls.  Martin
    Hi,
    As I understand you have a restriction on your PayPal account, unfortunately this is something Skype can't help you with.
    But you can try alternative payment methods: www.skype.com/intl/en-us/prices/ways-to-pay/
    Another option is to let your friend set up Skype Manager account, purchase credit there and allocate it to you: https://support.skype.com/en-us/faq/FA10519/What-is-Skype-Manager-and-how-does-it-work
    Andre
    If answer was helpful please mark it with Kudos and if issue is resolved mark it with solution. This will help other users find this answer more easily. Thanks in advance!

  • How to change web server from inbuilt Tomcat to IIS in already configured Cold Fusion 10

    how to change web server from inbuilt Tomcat to IIS in already configured Cold Fusion 10

    You just need to run the Web Server Configuration Tool to connect ColdFusion to IIS.  It can be found in the ColdFusion program group off of the Start menu.  Be sure to run it "As Administrator".
    -Carl V.

  • How to change apple ID from U.S to Asia when i still have credit on my U.S

    how to change apple ID from U.S to Asia when i still have credit on my U.S

    You're going to find that answer from Apple Support. Choose iTunes in Apple Support.
    Apple Support
    http://www.apple.com/support/

  • Some questions about how to change scenes

    i have something like the following:
    fxml (view/main/MainMenu.fxml):
    <Scene fx:controller="view.main.CtrlMainMenu" xmlns:fx="http://javafx.com/fxml" stylesheets="view/main/main.css">
        <GridPane xmlns:fx="http://javafx.com/fxml" alignment="center" id="backgorund" hgap="10" vgap="10">
            <!--other panes -->
            <VBox spacing="8" GridPane.columnIndex="0" GridPane.rowIndex="1">
                <Button text="Start" onAction="#Start"/>
                <Button text="Options" onAction="#Options"/>
                <Button text="Exit" onAction="#Exit"/>
            </VBox>
        </GridPane>
    </Scene>main loop (cotroller/main.java):
    public class main extends Application{
        public static void main(String[] args){
            launch(main.class, args);
        public void start(Stage stage) throws Exception{
            stage.setTitle(CtrlLanguage.get(CtrlLanguage.TITLE));
            CtrlMainMenu main = new CtrlMainMenu();
            Scene scene = main.main();          //don't know how to make Scene scene = (Scene)FXMLLoader.load(getClass().getResource("MainMenu.fxml")); work on here since MainMenu.fxml is in view/main while the main class is in controller and ended up putting CtrlMainMenu in the view although is not very correct
            stage.setScene(scene);
            stage.setWidth(1080);
            stage.setHeight(720);
            stage.show();
    }view controller (view/main/CtrlMainMenu.java):
    public class CtrlMainMenu{
        //other buttons actions
        public Scene main() throws Exception{
            return (Scene)FXMLLoader.load(getClass().getResource("MainMenu.fxml"));
        @FXML protected void Start(ActionEvent event){
        @FXML protected void Options(ActionEvent event){
        @FXML protected void Exit(ActionEvent event){
            System.exit(0);          //is there any other way to finish the program than using a system.exit?
    }got few questions currently:
    1. i'd like to be able to keep using CtrlMainMenu for other buttons while the ones that appear there go to the main (since will be reusing those classes from other scenes)
    tried adding fx:controller on panes instead of the scene, but it doesnt work at all (it crashes) else directly in CtrlMainMenu change the scenes of the stage, but then, i have to send the stage to every controller i use? (or how do i know the stage of the scene?)
    and in the case of options, i'd like after done, go back to the previous scene, is that possible? if so, how?
    2.if i want to implement languages, how do i do to change the text? tried with setText() but depending on where do i put it, it crashes, so dont know where do i have to put it
    3.im doing a game that may have different number of players, so, is there some way to erase/hide/add data from a gridpane with fxml?

    1. ok, found the way to change scenes, with this way:
    @FXML protected void Start(ActionEvent event) throws Exception{
         Node node = (Node)event.getSource();
         Stage stage = (Stage)node.getScene().getWindow();
         Scene scene = (Scene)FXMLLoader.load(getClass().getResource("../view/main/MainMenu.fxml"));     //this is just an example, will change to go to another scene
         stage.setScene(scene);
         stage.show();
    }but now i have another problem, when i click on the button the stage scene is changed, but the scene is transformed to a very small one at the top left (the size seems the same as when i dont put the set width/height on the stage when creating it), the stage size remains the same, and when i resize the window, it gets "repaired"
    the options, i thought on using a pane over the current pane so this way instead of going back would be just removing that new pane, would that work well?
    2. found about languages that is by using <Label text="%myText"/> and java.util.ResourceBundle but don't know how to use it, can someone provide me an example, please?
    3. still haven't looked on it...

  • How to plot XY graph from 2 input of dynamic array ? ...

    I have 2 problem when I plot XY graph with 2 dynamic array :
    - I want to make the graph look like sweep chart. But it's seem not possible to use waveform graph?
    - The graph shoul move from left to right , then right to left, then left to right,.....
    Any one can give me some hints?  Thanks alot.
    Attachments:
    U1.PNG ‏21 KB
    XY radom value input.vi ‏147 KB

    I have to make Y change  from 0-10, then 10-0,.... Any one can help me to make it better?
    - How I shift the graph?
    Attachments:
    working_increse_decrease.vi ‏20 KB

  • How to change column "Date" from "Text" to "Date-Time" in Document Library.

    How to change column name "Date" from "Single line of Text" to "Date and Time" in Document Library.

    Hi,
    If you would change column type, you might need to re-create column.
    If you would like a text column to display in date format, you could refer to the links below:
    http://sharepoint.stackexchange.com/questions/45774/how-to-convert-date-field-in-single-line-of-text-using-calculated-columns
    http://yasuanantha.blogspot.com/2008/06/to-convert-text-column-to-date-column.html
    Regards,
    Rebecca Tu
    TechNet Community Support

  • How to remove an email from a thread?

    I am relatively new to mail (migrated from entourage) and it's grouping totally unrelated emails because they have the same subject (hey or hi being very common subjects) and i would like to remove some of the emails from a thread. How can i do this?
    Second - is there a way to set it up so it only threads them together if the sender AND subject are the same (ie. original title or re: original title).
    Thanks!

    Not that I know of, it seems to be either on or off. Personally I turned off message threading for those reasons. I've found using Smart Folders a much more useful way of grouping my Mail.

  • How to change pdf font from "Type1" to "True Type"

    Hi all,
    really i need immidiate help from anybody. I have a pdf which is having font as "Type1"  when I am coverting it to swf it is not searchable. I know the solution for the issue to change the font from "Type 1" to "True Type", but I didn't know how to change the Font Type.
    Please help me. I have attached the sample pdf.
    Many Thanks!
    Prasanna

    Hi,
    You have to change the font in the smartform. Then convert the smartform output to PDF.
    Regards,
    Soumya.

  • How to change data format from  MM/DD/YYYY to DD/MM/YYYY

    HI,
    How can we change data format from MM/DD/YYYY to DD/MM/YYYY in Prompt and Report Level in obiee 11g.
    Please help me ont this.
    Thanks

    Hi,
    In Prompt:
    Try using EVALUATE function.
    Eg: Evaluate('TO_CHAR(%1,%2)' as character(30),"D5.Times"."Day Date",'DD-MON-YYYY')
    Report level:
    Try this in the column formula-
    Evaluate('TO_CHAR(%1,%2)' as character(30),"D5.Times"."Day Date",'MM/DD/YYYY')
    (or)
    EVALUATE('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), "Dim- Date".Start Date, 'MON-YY')
    http://108obiee.blogspot.in/2009/03/how-to-change-date-format-mask-in-date.html
    http://obiee-bip.blogspot.in/2011/08/customizing-obiee-calendar-display.html
    Some other methods.
    Metdhod 1:
    'Save System-Wide Column Formats' Option
    Check this.
    http://siebel-essentials.blogspot.com/2010/10/11-obiee-11g-tips-9-system-wide.html?m=1
    Thanks
    satya

  • How to change data type from Integer to Double?

    In a data set, BIP treat Oracle number type column as Integer. How to change it to double?

    Hi,
    This could be possible with the tcode RSD2 in BW.
    But before you do this you need to remove this KF from the cubes/dso in which they are used.Otherwise i don think you can do this.
    Once the change is done you could add them back to the DataTargets and load the data as required.
    Regards,
    Anoop

  • How to Change the Fields from Input mode to display mode

    Hi experts,
    Here is my business requirement. I need to show certain fields in the PRICING TAB OF SALES ORDER  in display mode. Now for this i am using the BADI definition CRM_PRICING_BADI.
       Now, can anybody tell me how to change the field type from input mode to change mode?

    Hi Karan,
      In your BADI has a parameter CT_INPUT_FIELD_NAMES with one field called CHANGEABLE with values:
         Field Can Be Changed
    A     Field Cannot Be Changed
       Assing this values to your fields according with your requirements.
    Regards.
    Manuel

Maybe you are looking for

  • Time_Out when running transaction S_ALR_87100205

    All , Whenever we are trying to execute the transaction S_ALR_87100205 it is giving us runtime TIME_OUT error. The error is occuring at SELECT...ENDSELECT statements. Please provide your valuable feedbacks or SAP notes to resolve this urgent problem.

  • Converting aac files to aiff format in iTunes 8.0

    I've always been able to convert files by using the preferences, advanced, import tab on iTunes. With 8.0, I can convert to mp3 format without having to go through preferences, but there is no place to convert an aac (mp4) to an aiff, which is what I

  • How to sequence an album in Logic?

    How can I sequence an album, meaning have songs blend into each other (one starts as the other fades away), while being able to seperate them into individual numbered tracks?

  • XI overview and links

    Hi, I am a newbie to SAP and from a Java background. I hoping that someone could help me find some materials about XI overview. Thanks, Chetan

  • Screen exit for ME21N/22N/23N

    Hi All. I have created all the subscreens available for enhancement MM06E005 (sub. scr. 0101, 0111, 0201, 0211, 0301 and 0311) , and have put a text inside each subscreen. All I want so far is to see this text in transactions ME21N/22N/23N, but I can