How to reload the screen when changing languages in JavaFX 2?

I'm beginner with javaFX and i need to change language of the screen. but i have no idea how to reload the screen when the language was changed. The application have a button where have the language available. I want just refresh screen when the user change language.
Here is the start method to show the stage.
    @Override
    public void start(Stage stage) throws Exception
        this.stage = stage;
        Locale locale = Locale.getDefault();
        ResourceBundle rb = ResourceBundle.getBundle("resources/Label",locale);
        loader = new FXMLLoader(getClass().getResource("FXMLDocument.fxml"),rb);
        root = (Parent)loader.load();
        FXMLDocumentController controller = (FXMLDocumentController) loader.getController();
        controller.setMain(this);
        scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
here is the function to change the language(in the same class with start function),the rb is the new ResourceBundle:
    public void refresh(ResourceBundle rb)
          //change the language here
1. I don't want to use the resourceBundle to get value in resource file and set label in scene one by one.like following:
this.btnLabel.setText(rb.getString(key.test));
2. I don't want to reload the scene,like following:
    public void refresh(ResourceBundle rb)
         try
            loader = new FXMLLoader(getClass().getResource("FXMLDocument.fxml"),rb);
            root = (Parent)loader.load();
            scene.setRoot(root);
            FXMLDocumentController controller = (FXMLDocumentController) loader.getController();
            controller.setMain(this);
        catch(Exception err)
            err.printStackTrace();
So do we have a solution to just set the resourceBundle and reload the scene easier?
Thanks and best regards!

Your option 2 (reload the FXML for the scene using the new resource bundle as a parameter), is the way this would normally be done and what I would recommend.
Failing that, you could use option 1 of individually resetting the label text of labeled items (I don't really recommend this).
Why don't you want to use option 2?
Perhaps it is because there is some internal state of the UI which differs from the initial state when the the UI is first loaded (e.g. user has typed text in a text field and you want to preserve that).  If that's the case you will need to either go with your option 1 of individually resetting the label text of labeled items, or implement something which preserves the UI state and user data by saving it in memory or to disk, reloading the UI via the FXMLLoader (essentially your option 2), then restoring the UI state and user data to what it was before the language change.  Preserving and restoring the modified state seems complicated to me if you have a lot of state, so I wouldn't really advise this approach unless you really needed it.

Similar Messages

  • How to update the table when change list item in classic report

    hi ,
    i worked with apex 4.2 and i create normal classic report with one select list(named loved)Column ,now i want to update table when user change the list with new value ,i can't create dynamic action to do this,i create check box with primary key and loop for check item to update the table but i can't get the value of list item. and for more speed the user want to do this when change the list value.
    my question
    1- how to do this by javascript and get the value from list item and update the table with new value
    2- is i must use API to create list item so i can get the value of item in report or what.
    Thanks
    Ahmed

    I coded the following to give you direction:
    1. In the "Element Attributes" section of the DEPTNO column, I call a javascript function as:
    onchange = "javascript:updateTable(this);"2. I wrote a simple javascript function that shows an alert when the user changes the select list as:
    <script language="JavaScript" type="text/javascript">
    function updateTable(pThis)
        var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
        alert('Row# - '+ vRow + ' has the value - ' + pThis.value);
    </script>Now, you can call a AJAX on-demand process inside the javascript function to update the database value.

  • I dropped my iphone vertically on the ground. The screen is normal when it is locked. but when unlocked, it is broken down from the clock. Can it be fixed and is it under the warranty conditions? If not how much is the price to change the screen?Thanks

    I dropped my iphone vertically on the ground.The screen works when it is locked.When unlocked, it's broken down from the clock.Can it be fixed and is it under warranty conditions?If not how much is the price to change the screen?Thanks

    User damage is not covered by warranty unless you have Applecare +
    assuming you do not,  the out of warranty exchange price for an iPhone 4 is $149,exchange at an Apple Store genius bar
    iPhone 4 are not repaired they are exchanged

  • How do you get your text messages to not show on the screen when they come in

    How do you get your text messages to show on the screen when then come in?  My iphone 3s would just say the persons name and text message.  This says the persons name and the whole message

    Settings > Notifications > Messages > Show Preview - Turn to OFF

  • How can I add a language on pages (Greek) to check the spelling when that language is not on the list?

    how can I add a language on pages (Greek) to check the spelling when that language is not on the list?
    I can see other languages available for spelling check, but not Greek and I dont see how to add it.
    I have added the Greek keyboard on the Mac, so I can write in Greek , but I dont know how to check the spelling in Greek on pages

    You can try to add a 3rd party spellchecker
    http://milaraki.com/blog/2010/11/greek-spelling-at-pages-how-to/

  • My Macbook display changes color when I open applications. It looks like there is a light blue layer over the screen, thus changing the color of my display. This layer goes away when i quit the applications.

    I am facing a problem and I am not sure if its a graphic card malfunction. When I open applications like Chrome, VLC player, and most apps, my display suddenly changes color. It is as though the Theme was changed. The normal grey panel on opened windows turns to light blue and everything else seem as though there is a light blue layer on top of it. When I close these applications (quit) the display returns to its normal self.
    My MacBook Pro is 2 years old, and I have an extended warranty. Will Apple replace my graphic card if it is actuall the graphic card's problem?

    I had that problem, too, and it's been documented both here and on the Adobe forums. What happens is that when you have dynamic switching on, when an application that uses your discrete GPU kicks in, the screen will change color. My problem lasted for a couple of weeks then just vanished.
    What you need to do is download Cody Krieger's gfxCardStatus and turn off dynamic switching and leave your GPU set to discrete only. That's the only fix that I know of at this time. I don't know why it happens or why mine stopped.
    Good luck,
    Clinton

  • I accidently erased all content on my ipad, now the only thing that comes on the screen is a language portal and it is some foreign language, cannot change it??

    I accidently erased all content on my ipad, (which my son had set up for me) now the only thing that is on the screen is a language portal, and some language I do not understand.  I cannot change anything on the screen, HELP???

    Slide to unlock then follow the process until you find back from itunes or icloud.

  • I was upgrading my iOS last night but when I checked to see the progress ,the home page refused to show. After d apple icon comes on the screen immediately changes to show the iTunes icon with a charging port cable

    I was upgrading my iOS last night but when I checked to see the progress ,the home page refused to show. After d apple icon comes on the screen immediately changes to show the iTunes icon with a charging port cable. What should I do?

    That means that you have to connect your iPad to your computer and you need to use iTunes to restore the iOS. Software. Read this for the instructions.
    iTunes: Restoring iOS software - Support - Apple

  • My iPad 2 randomly had a line going down the screen when I switched it on today, does anyone know why this is or how to get rid of it ?

    My iPad 2 randomly had a line going down the screen when I switched it on today, does anyone know why this is or how to get rid of it ?

    Hello there, Adavidson137.
    The following Knowledge Base article offers some great clarification on display anomalies:
    About LCD display pixel anomalies for Apple products released in 2010 and later
    http://support.apple.com/kb/ht4044
    The following steps for troubleshooting iPhone display issues can also be useful for your iPad as well:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/ts2802
    Display image issues
    This can include bright or dark pixels, lines in video, or sections of video missing.
    Try turning iPhone off and then on again.
    Verify the issue is not content related, by viewing different content.
    If the image is too dark, adjust the brightness. In General Settings choose Brightness and Wallpaperand slide the slider.
    My issue is still not resolved. What do I do next?
    Contact Apple Support.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • How can I make iPhone 4S Video's fill the screen when using them in iMovie 11 on My MacBook Pro

    Hey Guys.
    I am a singer songwriter from he UK.... I recently bought an Iphone4s, Ipad and Mac book pro (haha, apple hero, I know). I have always wanted to make the big jump to apple, just was waiting a little while.
    I am thrilled so far, it's all great. But, I use Imovie (i am still getting to grips with it, but the features are amazing) to make videos of me singing coversand original videos for youtube.
    The Camera on the iphone4s is great.
    But, when I import videos into Imovie11, the videos do not fill the screen in their original form.
    In some videos, I use the Ken Burns effect. Now, on the parts of my video when I use this effect, it fills the screen as it should do.
    Why do the videos in their untampered form not do this?  I have tried importing widescreen, original size, and Large, but it alwys sits in the middle of the screen, fairly thin lookin. It fills the screen when it's on my Iphone, I am very lost.
    plesse help.
    thanks.

    if i can offer any more info please just ask

  • How to get the screen number in the change/display FI Document screen?

    Hi guys,
    I was just wondering if there is a way, in the abap dictionary or otherwise, for me to detect the assigned screen number in the FI Change/Display Document screen (FB02/FB03)?
    I ask this because the screen number changes depending on the line item's posting key and G/L Account from my observation.
    Hope to hear from all of you soon.
    Thank you all and good day.

    Yes you can get by the SHDB transaction
    GO to SHDB. click on the new recording... give the name of the recording as ZFB02.. enter the tcode FI02 and press start recording..
    Put the Document and open all required screens.. you need to put the values in the required fields to be caputred in the recording.
    Come back and save.
    Now, if you are planning to make a BDC to change the FI document than you can use the BAPI BAPI_ACC_DOCUMENT_CHANGE.
    Regards,
    Naimesh Patel

  • How do I keep my cursor from flying to a random corner of the screen when I lift the mouse?

    My cursor contantly jumps to a random corner of the screen when I do a large movement or lift the mouse. Can I fix this?

    You can first do a SMC and PRAM reset. You can also restart in Safe Mode to reset some caches. However first I would look at the preferences for the mouse in System Preferences.
    SMC RESET
    Shut down the computer.
    Unplug the computer's power cord and all peripherals.
    Press and hold the power button for 5 seconds.
    Release the power button.
    Attach the computers power cable.
    Press the power button to turn on the computer.
    PRAM RESET
    Shut down the computer.
    Locate the following keys on the keyboard: Command, Option, P, and R. You will need to hold these keys down simultaneously in step 4.
    Turn on the computer.
    Press and hold the Command-Option-P-R keys. You must press this key combination before the gray screen appears.
    Hold the keys down until the computer restarts and you hear the startup sound for the second time.
    Release the keys.
    Roger

  • I have to press the button at the bottom up to 5 times to get the screen to change.  How can I fix this?

    I have had my i phone 4 for a few months now.  Lately I have to press the button at the bottom multiple times (up to 5) to get the screen to change.  Any way to fix this?  Thanks

    You can try basic from the manual:
    iPhone User Guide (For iOS 4.2 and 4.3 Software)
    Otherwise, make an appointment at the Genius Bar.  If it is defective, then they will replace.

  • How to see the MM invoice changes in sap?

    Hi
    How to see the MM invoice changes in sap ?

    Dear Prashant,
    When ever we perform LIV and is blocked for payment (due to price variance or other variance) is stored on table RBKP_BLOCKED
    Now when we release it through t. Code MRBR that time its get deleted from RBKP_BLOCKED
    So you can always track it :
    Go to ->SE16 ->Enter table name CDHDR -.>Table contents (F7)
    In the selection screen enter
    OBJECTCLAS as INCOMINGINVOICE
    OBJECTID as =Invoice no+year (e.g 51056066022011 where is 5105606602 invoice no 2011 is year)
    TCODE as MRBR
    ->Execute
    You will find the details when it was released  Date ,Time, User ID etc
    Edited by: redriver on Dec 26, 2011 2:23 PM

  • Reader XI has the print button off the screen when on 800x600 resolution

    Reader XI has the print button off the screen when on 800x600 resolution as well, how to fix without changing resolution?  A user needs the resolution set to that for her eyes.
    I see that this was an issue in Reader X and update 10.1.3 resolved it.  What was the fix?

    The scrollbar appears and works but unfortunately the dialog size is still too big therefore the print button ends up being hidden by the windows taskbar. Could you please make sure that the print dialog size is calculated against the work area (desktop size minus the taskbar, there's a win32 API to get that) rather than the whole desktop to fix the issue?
    That would also fix another issue: when the taskbar is sized higher than usual whatever the resolution you have it could still end up covering the print buttons but if you calculate against the work area rather than the desktop area that issue would be fixed as well.
    Please don't leave it unfixed because even if the requirements say 1024x768 if you have higher DPI settings or have a taskbar with a non-default size the print button could easily become unreacheable.

Maybe you are looking for