How can I display a new scene in JavaFX 2.2? For example after button click

how to display new scene after button click in the main window, I want the main window and the new scene are in one stage. thx

You can change the scene by calling stage.setScene(new Scene(newContentParent));
I don't think you are quite asking for a complete scene change though as you "want the main window and the scene in one stage". The main window is a stage (as Stage extends Window). And a given stage can only contain one scene at a time (though you can swap it out by calling setScene as described earlier).
What I think you are really asking for how can you replace some content part of the active Scene on the Stage. To do that you can set a layout manager like a HBox or a BorderPane as the root of your scene, then change out the content of the layout manager. For example:
final BorderPane layout = new BorderPane();
layout.setCenter(new Label("Dogbert");
final Button nav = new Button("Next");
layout.setLeft(nav);
nav.setOnAction(new EventHandler<ActionEvent>() {
  @Override public void handle(ActionEvent actionEvent) {
    layout.setCenter(new Label("Dilbert"));       
});In the above short sample code, if you wanted to change the scene rather than the a pane, then you would call stage.setScene rather than layout.setCenter.
There is a complete executable example with multiple content panes and some styling here:
http://stackoverflow.com/questions/13556637/how-to-have-menus-in-java-desktop-application

Similar Messages

  • How can I get a new copy of the Voicemail app for my LG Spectrum?

    How can I get a new copy of the Voicemail app for my LG Spectrum?  It no longer works....the screen say Loading please wait....the
    !Visual Voice Mail - A Visual Voice Mail error has occurred.  Please try again. OK   I've tryed several times with the same message.  I've
    deleted the app from my screen and replaced it from the Apps Library....still the same message.
    I cannot find an answer on MyVerizon.  Any ideas?
    Thank you,
    Dee

    OK, at least 3 is working.
    I don't know how you have a Tape Recorder icon on your Home Screen. I cannot add one myself. But, I am running Holo Launcher in replacement of the default LG "Optimus" User Interface. It's much better in my opinion.
    Try long pressing the icon and select Edit and maybe you can change some attribute of the icon.
    Another thing you could do, is long-press an empty area of your desktop, to add an icon. Select Shortcut, then Select Contact, and scroll through your contact list and choose the contact that you added for *86.
    You realize if you have voice mail you haven't heard, there is a tape recorder icon in the notification bar, which you touch and pull down, then press it to dial voicemail.
    If that functionality doesn't work, you MIGHT want to consider doing a factory data reset on your device, but that is going to nuke all your personalizations and cause you work to set up again.

  • HT201303 How can you tell which devices used the Apple ID? For example: "twoPads, 2 iPhones and 1 computer used your Apple ID ?"

    I believe my kid gave somebody my password to download something. And I want to know who? Can it say  For example: "2 iPads, 2 iPhones and 1 computer used your Apple ID ?"

    Only if they went to the trouble of setting their device up as a "Managed Device" on your ID.
    Change your password.

  • How can I accept the new terms of itunes store ? There's no button "accept"

    Since  2 days i use io7.
    I want to upload a new app, but my iphone says "new conditions of itune store, read them and accept them"
    Ok, but there is nothing for i accept on the screen, just "cancel" !!
    I can push on "send by e-mail" but it doesn't work !!!!!

    Hello Pic92700,
    Thank you for using Apple Support Communities.
    It sounds like you are stuck at this Terms and Conditions screen and cannot get past it.
    I recommend either, restarting the phone, or resetting if you cannot restart it with this article:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    Cheers,
    Sterling

  • How can I syncronize raiting of my songs between Itunes and for example AIMP?

    sometimes I need this, cant find anything in Internet about it...

    Hey I had the same problem-
    The fix to solve the error was quick and easy:
    -Go to My Music tab and click on the song view to show all tracks.
    -Then simply organize by the iCloud Download column. (if not shown, right click the column menu)
    -The songs without any sort of iCloud icon shown are the ones with the error as you mentioned.
    -Select all of those and hit delete. It will then ask to delete off of iCloud but make sure to click NO.
    Voila no more annoying error on every SINGLE track over and over. I felt your pain, and now we are free!

  • How to display another scene after button click

    In my Application, I've already create tool bar and menu bar at the top, a navigation panel on the left, and a working area in the center. I have an introduction page in opening my application, but I have a problem, when I click a new project button in my navigation panel to show a scene in working area.. a new scene display separately with main window.. I want that scene integrated with main window, can you help me to solve this problem?
    Edited by: 973863 on Dec 2, 2012 6:28 AM

    Has this question not already been answered?
    How can I display a new scene in JavaFX 2.2? For example after button click

  • How can I display the name of my refnum on the front panel?

    I am writing data to a file. To do this, I am using "Open/Create/Replace File" to prompt the user for a filename, which is then output to my VI as a refnum. I then write strings to this file with "Write to Text File".
    How can I display this filename (with the path) on the front panel after the user has input it?
    Michael
    Solved!
    Go to Solution.
    Attachments:
    refnum.JPG ‏45 KB

    Use the Refnum to Path function, in File I/O -> Advanced File Functions palette. You can wire this to a path indicator.

  • How can I add a new categorie?

    How can I add a new categorie in iBooks

    Hi jjquintas,
    Thanks for using Apple Support Communities.  This article has information on how to organize your books in iBooks for Mac, including adding a new collection:
    iBooks for Mac: Organize your books
    http://support.apple.com/kb/PH14763
    Add a collection:
    Click Collections, then click Add in the bottom-left corner. You can also select books, then choose File > New Collection from Selection.
    Cheers,
    - Ari

  • How do i run a new software program (Investment Account Manager for Windows) using Windows emulation software?

    How can I run a new software program (Investment Account Manager for Windows) using Windows emulation software?

    You will need a licensed copy of Windows 7, and I recommend VMFusion. You can run the program in Unity mode just as if it were a Mac application. Or, you can install Windows in Bootcamp and run the Mac in Windows when you boot and run it that way. Depends on the resources. I prefer the VM method because it is cleaner and gives you more options as far as backups, etc.

  • How can I use this account without specify credit cards, only for free applications ?

    How can I use this account without specify credit cards, only for free applications ?

    Click here and follow the instructions.
    (94222)

  • Exporting photos for UHDTV or Native 4K TV, what are the best settings ? (File: Quality File: Color Space, Image Sizing and resolution)   Or in other words; How can I get the smallest files but keep good quality for display on new UHDTV

    Exporting photos for UHDTV or Native 4K TV, what are the best settings ? (File: Quality File: Color Space, Image Sizing and resolution)   Or in other words; How can I get the smallest files but keep good quality for display on new UHDTV

    You're welcome, and thank you for the reply.
    2) Yesterday I made the subclips with the In-Out Points and Command-U, the benefit is that I've seen the clip before naming it. Now I'm using markers, it's benefit is that I can write comment and (the later) clip name at once, the drawback is that I have to view to the next shot's beginning before knowing what the shot contains.
    But now I found out that I can reconnect my clips independently to the format I converted the master clip to. I reconnected the media to the original AVI file and it worked, too! The more I work with, the more I'm sold on it... - although it doesn't seem to be able to read and use the date information within the DV AVI.
    1) Ok, I tried something similar within FCE. Just worked, but the file size still remains. Which codec settings should I use? Is the export to DV in MOV with a quality of 75% acceptable for both file size and quality? Or would be encoding as H.264 with best quality an option for archiving, knowing that I have to convert it back to DV if I (maybe) wan't to use it for editing later? Or anything else?
    Thank's in advance again,
    André

  • I have a question about the new version of itunes. in the old version at the bottom of the sceen it display the total number of media and the size of the files. how can i get the new version to diplay this?

    in the old version at the bottom of the sceen it displayed the total number of media and the size of the files. how can i get the new version to diplay this?

    You're welcome. It was frustrating for me as well until I stumbled across "the fix"

  • How can we display 2 rows in a single row with new coulmn names?

    Hi,
    I have a requiment as shown below.
    ME A_END Z_END
    1 aaaa
    2 zzzzz
    I need the above data in the below format.
    A_ME Z_ME A_END Z_END
    1 2 aaaa zzzzz
    How can we achive this?

    user6755466 wrote:
    Hi Alex,
    Thanks for your quick response.
    Actually the coulmns ME_ID, A-END, Z-END, etc doesn't have fixed values as you hard coded with values (e.g., 1, 2) in your query.One way is to assign a "row number" to each row and then pivot using the known row numbers of 1, 2 ... etc.
    Example:
    SQL> ed
    Wrote file afiedt.buf
      1  with test as
      2  (
      3  select 3 a_end, 'aaaa ' z_end from dual union all
      4  select 5 a_end, 'zzzzz' z_end from dual
      5  )
      6  select max (decode (rn, 1, a_end)) a_me
      7       , max (decode (rn, 2, a_end)) z_me
      8       , max (decode (rn, 1, z_end)) a_end
      9       , max (decode (rn, 2, z_end)) z_end
    10  from (select a_end, z_end
    11              ,row_number() over (order by a_end, z_end) as rn
    12*       from test)
    SQL> /
          A_ME       Z_ME A_END Z_END
             3          5 aaaa  zzzzz
    SQL>Here, the values are 3 and 5, but they are assigned a row number based on the order of them and then the decode uses that row number to pivot them.
    Of course, as everyone else has pointed out, the best place to be doing this is in a dedicated reporting tool. SQL is not the best of places to pivot data for reporting purposes.

  • How can I display XSLT transformer errors on a web page ?

    Hi,
    I have some JSP pages that access DB, create an XML based on DB data and then transform it into HTML through an XSLT stylesheet. Developing the XSL code it's easy to make mistakes and generate errors on trasformation, but what I receive on the web page is only a "Could not compile stylesheet" TransformerConfigurationException, while the real cause of the error is displayed only on tomcat logs. This is the code for transformation:
    static public void applyXSLT(Document docXML, InputStream isXSL, PrintWriter pw) throws TransformerException, Exception {
            // instantiate the TransformerFactory.
            TransformerFactory tFactory = TransformerFactory.newInstance();
            // creates an error listener
            XslErrorListener xel = new XslErrorListener();
            // sets the error listener for the factory
            tFactory.setErrorListener(xel);
            // generate the transformer
            Transformer transformer = tFactory.newTransformer(new SAXSource(new InputSource(isXSL)));
            // transforms the XML Source and sends the output to the HTTP response
            transformer.transform(new DOMSource(docXML), new StreamResult(pw));
    }If an exception is thrown during the execution of this code, its error message is displayed on the web page.
    This is the listener class:
    public class XslErrorListener implements ErrorListener {
        public XslErrorListener() {
        public void warning(TransformerException ex) {
            // logs on error log
            System.err.println("\n\nWarning on XEL: " + ex.getMessage());
        public void error(TransformerException ex) throws TransformerException {
            // logs on error log
            System.err.println("\n\nError on XEL: " + ex.getMessage());
            // and throws it
            throw ex;
        public void fatalError(TransformerException ex) throws TransformerException {
            // logs on error log
            System.err.println("\n\nFatal Error on XEL: " + ex.getMessage());
            // and throws it
            throw ex;
    }When I have an error in the XSL stylesheet (for examples a missing closing tag), I can find on tomcat logs the real cause of the error:
    [Fatal Error] :59:10: The element type "table" must be terminated by the matching end-tag "</table>".
    Error on XEL: The element type "table" must be terminated by the matching end-tag "</table>".but on my web page is reported just the TransformerConfigurationException message that is:
    "Could not compile stylesheet".
    How can I display the real cause of the error directly on the web page?
    Thanks,
    Andrea

    This code is part of a bigger project that let developers edit XSL stylesheets through a file upload on the system and we can't impose the use of any tool for checking the xsl. So, I need to display the transformer error on the web page.I see. This code is part of an editorial/developmental tool for developers to create and edit XSL stylesheets.
    As part of the editorial process, XSL errors during editing can be considered a normal condition. In other words, it is normal to expect that the developers will generate XSL errors as they are developing stylesheets.
    In this light, handling the XSL transformation errors is a business requirement that you need to handle. Using the Java Exceptions mechanisms, e.g. try / catch are inappropriate to handle business requirements, in my opinion.
    I suggest that you look at how you handle the occurence of XSL errors differently than what you currently have. You need to:
    (1) capture the Transformation exception on the server;
    (2) extract the message from the exception and put it into a message that can be easily understood by the user;
    The current error message that you have going to the web browser is not useful.
    And you should not have the Transformation exception sent to the web browser either.
    What you are attempting to do with the exception is not appropriate.
    Handle the Transformation exception on the Business tier and use it to create a useful message that is then sent to the Presentation tier. In other words, do not send Java exceptions to web browser.
    />

  • How can I display True/False in my dropdownlist as "Yes" and "No"?

    Hi All,
    I want to bind a dropdownlist to a boolean value (so it's either true or false).  I'm particularly interested in using two-way binding to when the user changes from "yes" to "no" the boolean value automatically changes from "true" to "false."  But, I want the user to see "yes" and "no" as the options, rather than "true" and "false".
    How can I display "yes" and "no" and still take advantage of binding?  Or can I not use binding in this circumstance?
      -Josh

    Solution 1:
    In order to display Yes/No for True/False, you may specify labelFunction for the dropdownList.
    In MXML:
    <s:DropDownList labelFunction="myLabelFunction" />
    In actionscript:
    private var arr:ArrayCollection = new ArrayCollection(["true","false"]);
                private function mylabelFunction(item:Object):String
                    if(item.toString() == "true")
                        return "yes";
                    else return "No";
    OR
    Solution2:
    may be u can try making an array collection like
    private var arr:ArrayCollection = new ArrayCollection([{label:"yes",value:"true"},{label:"no",value:"false"}]);
    and specify labelField for the dropdownList like
    <s:DropDownList labelField="label" dataProvider="{arr}" />

Maybe you are looking for