Why does Scene Builder constantly create new instances of Nodes?

Hi,
I thought I had a simple idea for creating a control that would let me get some of the behavior of a card pane.  This is the entire control:
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.layout.StackPane;
public class Card extends StackPane {
    private final BooleanProperty active = new SimpleBooleanProperty();
    public final BooleanProperty activeProperty() {return active;}
    public final boolean isActive() {return active.get();}
    public final void setActive(boolean active) {this.active.set(active);}
        visibleProperty().bind(active);
        managedProperty().bind(active);
        active.addListener(new ChangeListener<Boolean>() {
            @Override
            public void changed(ObservableValue<? extends Boolean> observable,
                                Boolean old,
                                Boolean active) {
                System.out.println(toString() + " active changed to: " + active);
                if(active) {
                    Parent parent = getParent();
                    if(parent != null) {
                        System.out.println("Parent is: " + parent.toString());
                        parent.getChildrenUnmodifiable().forEach(Card.this::deactivateIfCard);
                    else {
                        System.out.println("Parent is null.");
    private void deactivateIfCard(Node node) {
        if(node != this && node instanceof Card) {
            Card card = (Card) node;
            card.setActive(false);
The idea is pretty simple; extend StackPane, add an active property, bind the visible and managed properties of the pane to the active property, and, whenever the active property is changed to true, iterate sibling nodes de-activating any siblings that are also of the type Card.
However, this doesn't work with Scene Builder.  While trying to debug, I created an ExtStackPane:
import javafx.collections.ListChangeListener;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
public class ExtStackPane extends StackPane {
        getChildren().addListener((ListChangeListener<Node>) c -> {
            System.out.println("ExtStackPane children change: " + c.toString());
All this does is log list change events.  However, I was very surprised by the output when working in Scene Builder.  I added both controls to Scene Builder and did the following:
0) Added an ExtStackPane
1) Added a Card to the ExtStackPane
2) Added another Card to the ExtStackPane
3) Added a Label to the first Card
4) Added a Label to the second Card
5) Changed the text of the first Label to Hello
6) Changed the text of the second Label to World
7) Set the first Card to active
8) Set the second Card to active
I get the following output:
1)
ExtStackPane children change: { [Card@5b9067b3] added at 0 }
2)
ExtStackPane children change: { [Card@6b6328bd] added at 0 }
ExtStackPane children change: { [Card@6aca8cc5] added at 1 }
3)
ExtStackPane children change: { [Card@3b7bc340] added at 0 }
ExtStackPane children change: { [Card@1879819e] added at 1 }
4)
ExtStackPane children change: { [Card@60ffed67] added at 0 }
ExtStackPane children change: { [Card@64955a14] added at 1 }
5)
ExtStackPane children change: { [Card@5dc96bc4] added at 0 }
ExtStackPane children change: { [Card@40667c26] added at 1 }
6)
ExtStackPane children change: { [Card@164770fa] added at 0 }
ExtStackPane children change: { [Card@7decebbf] added at 1 }
7)
Card$1@f4f4850 active changed to: true
Parent is null.
ExtStackPane children change: { [Card@27442c8b] added at 0 }
ExtStackPane children change: { [Card@643d810e] added at 1 }
8)
Card$1@4877c67b active changed to: true
Parent is null.
ExtStackPane children change: { [Card@7e8a473e] added at 0 }
Card$1@2b4497c1 active changed to: true
Parent is null.
ExtStackPane children change: { [Card@5df6c8cc] added at 1 }
This is what things look like in Scene Builder:
Does Scene Builder recreate the entire hierarchy every time I make a small change?  Here's an application that does the same as the manual steps I performed in Scene Builder:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class CardApplication extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        ExtStackPane stackPane = new ExtStackPane();
        // 1
        Card card1 = new Card();
        stackPane.getChildren().add(card1);
        // 2
        Card card2 = new Card();
        stackPane.getChildren().add(card2);
        // 3
        Label label1 = new Label();
        card1.getChildren().add(label1);
        // 4
        Label label2 = new Label();
        card2.getChildren().add(label2);
        // 5
        label1.setText("Hello");
        // 6
        label2.setText("World");
        primaryStage.setScene(new Scene(stackPane));
        primaryStage.setTitle("Card Application");
        primaryStage.setWidth(600);
        primaryStage.setHeight(400);
        primaryStage.show();
        // 7
        card1.setActive(true);
        // 8
        card2.setActive(true);
The output when running the above is:
1)
ExtStackPane children change: { [Card@6dfaa767] added at 0 }
2)
ExtStackPane children change: { [Card@6aa2c411] added at 1 }
7)
Card$1@1abf7511 active changed to: true
Parent is: ExtStackPane@41993867[styleClass=root]
8)
Card$1@5733cd2 active changed to: true
Parent is: ExtStackPane@41993867[styleClass=root]
Card$1@1abf7511 active changed to: false
The behavior is obviously a lot different than when I'm working with the control in Scene Builder.  Can anyone explain to me what Scene Builder is doing to change the behavior of my Card control so much?  Does my Card control break some rule(s) I'm not aware of?

I think you're confused about what SceneBuilder is doing.
SceneBuilder is a design tool, used by the programmer (not the end user) to generate part of the code that is used to execute the application. (Specifically, it generates the FXML code that is parsed by the FXMLLoader to create and configure objects that are typically part of the scene graph.)
While you are using SceneBuilder to create the code, it generates a mock-up of what the UI will look like, if the generated FXML were to be loaded and displayed. This mock-up is not supposed to be an identical view of what the end user will see, but an aid to you, as the programmer, to generate the code you want.
So, for your Accordion/TitledPane example, in the mock-up that SceneBuilder displays, the *selected* titled pane is always displayed expanded. This enables you to drag and drop items into it, and to configure it in other ways. If you uncheck the "expanded" checkbox in the properties pane, then it remains expanded in the mock-up so that you can continue to configure it. However, this property is not ignored: the state of those checkboxes is respected in the FXML file that is generated. So when you hit "save" in SceneBuilder, the generated fxml will contain TitledPane element with expanded="true" if the check box is checked, and expanded="false" if the check box is unchecked. (SceneBuilder will of course also enforce the rule that only one TitledPane in an Accordion can be expanded.)
Similarly, for your custom control, you should be able to set it up so SceneBuilder displays the "active" property in the check box. If you uncheck that property, so active=false, that will be respected in the fxml and when you execute the application, active will be set to false, and so by your binding, visible will be set to false and the component won't display. But the mock-up in SceneBuilder will (of course) still display your component, because it would be extremely difficult for you to configure a component that didn't appear in the programming tool.
In fact, there's no real reason for SceneBuilder to create any objects that you are configuring at all. It could just try to figure out what they look like and render a depiction of them on a canvas, for example. That's probably much (much) more difficult than instantiating them and the authors of SceneBuilder apparently chose to write SceneBuilder in a way that re-instantiated the controls many times. But that has absolutely nothing to do with what happens when you execute the application and it makes no sense at all to compare the two.

Similar Messages

  • Why does stuffit open and create a new folder every time I save a pages document?

    Why does stuffit open and create a new folder every time I save a pages document?

    Because you are saving it to the desktop, Pages documents are actually zipped files and Stuffit is set to uncompress desktop files.
    Either don't save to the desktop (bad practice) or check the preferences in Stuffit to see if you can turn off unstuff files on desktop.
    Peter

  • In Address Book, why does Apple let you create custom fields in the Template cards but not have them available for importing?

    I open Address Book, go into Preferences, select Template and under the Names field (friend, assistant, father, etc) I add a custom field called "Principal".
    I also add two more custom fields in the Email area.
    Quit Address Book then relaunch. Add a new contact and the new custom fields, Principal, etc. are there. All good so far.
    I have a Now Contact file with about 200 contacts in it. I export all fields as a Text file, Tab delimited. No problems there. With Address Book launched, select Import, pick the text file, leave Text Encoding on Automatic and click Open.
    The window that shows the fields for Address Book and fields for the text file side by side opens. This is where you match up the correct fields for importing. If I go to one of the fields from the text file that I created a custom field for, click under the Address Book heading on the Do not import, scroll thru the Apple choices of fields, none of the custom fields show up. Only the original Apple ones are there. Why does Apple let you create them in the Template area but not have them available for importing? Does anyone have suggestions on getting around this?

    While most likely not of interest to you, Spotlight can also tell you where the files it finds are located
    Hover the mouse pointer over the name, and press Command-Option and the path to the file will be displayed.
    As for opening a terminal session in the directory where a file is located, there is Applescripts that do just that as well as specific features in Lion/Mountain Lion terminal:
    <http://stackoverflow.com/questions/420456/open-terminal-here-in-mac-os-finder>
    <http://hints.macworld.com/article.php?story=20110729034827358>
    <http://www.macworld.com/article/1047793/folderinterm.html>
    <http://www.macworld.com/article/1161876/open_finder_folder_in_terminal.html>
    <http://www.macobserver.com/tmo/article/os_x_lion_open_a_folders_location_in_term inal>

  • Able to create new instances in Platform Edition 9.0?

    According to the Platform Edition 9.0 docs http://docs.sun.com/app/docs/doc/819-3662/6n5s9hmtq?a=view , it is possible to create new instances using create-instance command.
    However, I encountered an invalid command error in asadmin when trying to invoke create-instance:
    bash$ ./asadmin
    Use "exit" to exit and "help" for online help.
    asadmin> create-instance
    CLI147 Invalid command, create-instance
    asadmin>I am using Application Server Platform Edition 9.0_01 (build b14)
    SO, are we really able to create new instances in PE 9.0? Thanks in advance for any advice.

    Hi there !
    I don't belive of can perform these tasks on PE.
    The concepts of nodeagents , clusters and other are no present on the Platform edition.
    I also see no way of managing these new instances on the administration console, so ... my guess is it can be done
    Rp

  • Why does my browser constantly have to stop playing when watching You Tube?

    Why does my browser constantly have to stop playing when I watch You Tube or other videos?
    this is driving me nuts. It stops and then starts up again after a few seconds and then stops again and re-starts.
    Happens on both Safari and Firefox.
    Can anyone help?
    Message was edited by: kathrynfromsananselmo

    Hi Kathryn ...
    Most YouTube content requires the Flash plugin... try troubleshooting.
    Quit Safari and Firefox if they are open.
    Now uninstall the Flash plugin then reinstall new >  Troubleshoot Flash Player | Mac OS
    Use Safari to test. Launch Safari From your Safari menu bar click Safari > Empty Cache
    Now try a video.
    BTW... if you have the ClickToFlash extension installed in Safari > Preferences - Extensions, that can prevent Flash based video from streaming. It can also be installed as a plugin in /Library/Internet-Plug-Ins.
    And check to see if Safari is running in 32 bit mode. Right or control click the Safari icon in your Applications folder then click Get Info. If the box next to:  Open in 32 bit mode  is selected, deselect, quit then relaunch Safari to test.

  • ORA - 01034 : ORACLE NOT AVAILABLE  Error while creating new instance.

    I was trying to create new instance in unix environment. I have configured all my shell scripts to run and install but while performing the install I get the
    following error message and fails.
    ORA-01034: ORACLE not available
    I have previously installed an instance using same scripts but fails this time when I copy the scripts and modify them in new folder. Pointed out the path in the scripts correctly.
    I am a junior DBA and I would appriciate your help.

    Paste here scripts, your .profile (or environment variables according to Oracle) and your init.ora

  • Why i can't not create new database in oracle 10g express

    why i can't not create new database in oracle 10g express?
    should i use oracle 11g standard edition?
    thanks

    In Oracle a schema is what a 'database' is in Sqlserver.
    And if you would have been aware about the limitations of XE, you would have known you can only create *1* (one) database using Oracle XE.
    However, probably you don't need a new database at all, and a schema will suffice.
    Sybrand Bakker
    Senior Oracle DBA

  • Why does a standalone program created in Labview 8.5 try connecting to the internet when the program only reads data through the serial port? Firewalls object to progams that contact the internet without permission.

    why does a standalone program created in Labview 8.5 try connecting to the internet when the program only reads data through the serial port? Firewalls object to progams that contact the internet without permission.
    The created program is not performing a command I have written when it tries to connect to the internet, it must be Labview that is doing it. How do I stop this from happening? 
    Any help would be very appreciated.

    It looks that way..
    "When LabVIEW starts it contacts the service
    locator to removes all services for itself. This request is triggering
    the firewall.This is done in case there were services that were not
    unregistered the last time LabVIEW executed- for example from VIs that
    didn't clean up after themselves"
    This is not yet fixed in LV2009.
    Message Edited by Ray.R on 11-04-2009 12:25 PM

  • Why does the internet on my new macbook pro not work when my old macbook's does?

    Why does the internet on my new macbook pro not work when my old macbook's does? I'll have to turn the wifi off and back on multiple times to get the internet to continue to work on my Macbook Pro (running mountain lion but did it on lion also) when it runs fine on my old white Macbook (running lion). Is there something I can do to fix it or do I just have to deal with it?

    Here is your fix .. I have uploaded my properly calibrated profile get it here :
    http://www.megaupload.com/?d=YAJL6A9X
    And it should go to your user folder/Library/ColorSync/Profiles
    if you have one already you can rename either one ..
    and then go to system preferences - displays - color to select the profile .
    you will get rid of the blue tint while keeping correct color and gamma
    This is for the newer 2010 MBP's altho if same display was used might also give good results in the previous models as well . .

  • ODI 11g 11.1.1.7 with Win64 bit OS : Starange problem : Right click does not work for Create new data server in Topology.

    ODI 11g 11.1.1.7 with Win64 bit OS : Strange problem : Right click does not work for Create new data server in Topology.
    On right click nothing happens at all. I have  reinstall the ODI multiple times with right installer. issue persist.
    Please help.

    Hi,
    Did you use the generic installer or the win32 one ? You should use the former with Win64.
    You can also check that your version of Java is supported in the certification matrix.
    Regards,
    JeromeFr

  • Why does safari close constantly on ipad1?

    why does safari close constantly on ipad1

    Could be any one of many things.  Try these...
    Clearing Safari's history, cookies, cache
    Reset the iPad... press the home and sleep/lock buttons until you see the Apple logo, ignoring the slider. Takes about 5-15 secs of button holding and you won't lose any data or settings.
    Shut down and restart the app...
    - From any Home Screen, double tap the home button to bring up the Recents List
    - Tap and hold any icon in this list until they wiggle
    - Press the red to delete the offending app from this list.
    - Press the home button twice when done.
    - Restart the app

  • How to repaint an array of JCheckbox witou creating new instance?

    Can you help me on how I will repaint the array of check box, without creating new instance. When I pressed the refresh Button It will repaint the check box. Anybody who can help me..
    Here's my code. The Comment is the one I need to put the action.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class subok extends javax.swing.JFrame {
        JCheckBox c[] = new JCheckBox[10];
        public subok() {
            initComponents();
            setSize(300,500);
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            check();
            refresh = new javax.swing.JButton();
            getContentPane().setLayout(null);
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jPanel1.setLayout(null);
            refresh.setText("Refresh");
            refresh.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    repaintCheckbox(evt);
            jPanel1.add(refresh);
            refresh.setBounds(160, 260, 160, 23);
            getContentPane().add(jPanel1);
            jPanel1.setBounds(0, 0, 400, 300);
            pack();
        }// </editor-fold>                       
        private void repaintCheckbox(java.awt.event.ActionEvent evt) {                              
                // what will I put here???????
                // ANy Help will do....
                // I just want to refresh the checkbox when I pressed this button..
        public void check() {
            boolean s = false;
            int x = 10;
            for(int i = 0; i < 10; i++) {
                c[i] = new JCheckBox();
                c.setText("");
    c[i].setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    c[i].setMargin(new java.awt.Insets(0, 0, 0, 0));
    jPanel1.add(c[i]);
    c[i].setBounds(20, x, 73, 15);
    x += 30;
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new subok().setVisible(true);
    // Variables declaration - do not modify
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton refresh;
    // End of variables declaration

    what do you mean by repaint the checkboxes?
    do you mean setting them all to 'unchecked'?
    if so, just loop through your checkbox array c[x].setSelected(false);

  • Why does a PDF file created in Pages, attached to e-mail, not get sent?

    Why does a PDF file created in Pages, attached to e-mail, not get sent?  I even blank copied myself and nothing seems to have been sent.  Could it bee the size of the PDF file?

    They send for me, my test document was 3.8 MB.

  • Why does my iPad constantly ask for a keychain security access code?

    Why does my iPad constantly ask for a keychain security access code?

    You might have some app updates or other itmes that are trying to download.

  • Why does my web page, created on iWeb, look correct on Safari but has thick black lines all over it in Firefox?

    Why does my web page, created on iWeb, look correct on Safari but has thick black lines all over it in Firefox?

    What's the URL of your site so we can examine it first hand?  I assume those black lines are around photos or objects that have had a frame or drop shadow added to it, right?  If so that's a known issue. 
    There's a workaround for that in this tutorial: #7 - Converting Photos w/Frames, Drop Shadows and/or Reflections into a Single Image File.  That should get rid of those black lines/boxes.
    OT

Maybe you are looking for

  • Error Warning that Time Machine couldn't complete the backup to disk, an error occurred while copying files.

    I've been getting this warning on my MBA for the last week: "Time Machine couldn't complete the backup to "LaCie-2big-NAS." an error occurred while copying files. The problem may be temporary. If the problem persists, us Disk Utility to repair your b

  • Sync issues with iCal/MobileMe/Google

    Seems like I've come across something rather sticky.... History I have a MacBook Pro and an iPhone 3G. For the first few months of having the phone, syncing worked like a charm... no complaints. I then decided that I needed to get my Appointments etc

  • How good is the camera - honestly!

    The new iphone 3Gs has a 3mp camera. This isnt many pixels really when cameras are now around 12mp. What are your views on this?

  • Lookup API - asynchonous SOAP Adapter Queue

    Hi, I have a question about the queue handling, when you use the Lookup API of the SAP PI. ([Sap Help Lookup API|http://help.sap.com/saphelp_nw04/helpdata/en/cf/406642ea59c753e10000000a1550b0/frameset.htm]) When I call a synchronous Web Service via S

  • Dinamic Combobox in jDeveloper using JSP

    What is the most simple way to do a JSP page with two dinamic combobox like the classic Countries and Cities ... That is.. When I select a Country then all the cities of the country selected are loaded from a Data Base... I'm working in jDeveloper..