Why stage Builder creates constantly new instances of nodes?

Hello

I thought I had a simple idea to create a control that would allow me to recover a part of the behavior of a component of the map.  It's all of the 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 simple enough; expand StackPane, add an active property, bind the visible and managed component properties to the property active, and, whenever the active property is changed to true, browse the sibling nodes by disabling brothers and sisters who are also the type of card.

However, this does not work with the generator from the scene.  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());
        });
    }
}

It doesn't save that list change events.  However, I was very surprised by the exit when you work in the generator from the scene.  I added both controls the generator onstage and did the following:

0) added an ExtStackPane

(1) added a map to the ExtStackPane

2) added another card at the ExtStackPane

(3) adds a label the first card

(4) added a label to the second card

5) changed the text of the first label Hello

6) changed the text of the label of second in the world

(7) set the first card to active

(8) the value of the second card active

I get the following result:

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 the generator from the scene:

card-panes.PNG

The scene generator recreate the entire hierarchy whenever I make a small change?  Here's an app that does the same thing as the manual steps that I performed in the stage 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 executing 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 very different than when I work with control in the generator from the scene.  Can someone explain to me that event giving rise to the stage to change the behavior of my map control so much?  My map control breaks some I'm not aware of one or more rules?

I think you're confused about what makes SceneBuilder.

SceneBuilder is a design tool, used by the programmer (not the end user) to generate the part of the code that is used to run the application. (Specifically, it generates the FXML code which is analysed by the FXMLLoader to create and configure objects that are usually part of the graphic scene.)

When you use SceneBuilder to create the code, it generates a model of what the user interface will look like, if the generated FXML should be loaded and displayed. This model is not meant to be an identical vision of what will be the end user, but a help to you, the programmer, to generate the code that you want to.

So, for example your accordion/TitledPane in the layout of the poster than SceneBuilder, the * selected * titled pane is always expanded. This allows you to drag and drop objects inside and set it up in other ways. If you clear the checkbox "extended" in the properties pane, then it remains extended in the model so that you can continue to configure it. However, this property is not ignored: the State of these boxes is respected in the FXML file that is generated. So when you click on 'save' in SceneBuilder, the fxml generated will contain TitledPane extended element = "true" If the box is checked and expanded = "false" If the check box is cleared. (SceneBuilder will of course also applied the rule that only TitledPane in the accordion can be increased.)

Similarly, for your control customized, you should be able to implement and SceneBuilder displays the 'active' property in the box. If you disable this property, if active = false, which will be respected in the fxml and when you run the active application will be set to false and so by your liaison, visible is set to false and the component is not displayed. But the comp in (of course) SceneBuilder always displays your component, because it would be extremely difficult for you to configure a component that did not appear in the programming tool.

In fact, there is no real reason for SceneBuilder create all the objects that you set up at all. He could just trying to figure out what they look like and render a representation of them on a canvas, for example. It's probably much (much) harder than instantiating them and the authors of SceneBuilder apparently chose to write SceneBuilder in a way that re-instantiates the controls several times. But this has absolutely nothing to do with what happens when you run the application and it is no logic at all to compare the two.

Tags: Java

Similar Questions

  • Why Photoshop 6 creates a new layer of text whenever I want to edit an existing text layer?

    Why Photoshop 6 creates a new layer of text whenever I want to edit an existing text layer?

    You can choose the text tool in an effort to make a montage.

    Instead, double click on the T in the text layer.

  • Create the new instance to a diferent project

    Im trying to create a new instance in a project, I use an interactive global activity to do this, when trying to create the reception that this message in the BPM 'JavaLangNullPointerException', the global comprehensive interactive activity log is in a different project that I want to create the instance.

    This is the code I used in BPM

    args ['argPrueba'] = 1234

    Result2 = ProcessInstance.create (processId: "/ Test", arguments: args, argumentsSetName: "BeginIn")

    in the other project, I configure the beginIn of this way activity:

    idPrueba = argPrueba

    I used BPM 10g

    If you cannot create instances of processes in the same project, you need to double check your logic.

    1. check that 'args' is an array of associative strings (Any [String]).  Believe that the default value to a variable called "argsIn" (you have "args" in your logic).

    This means that Begin activity has two variables of the arguments
    named 'nameArg' and 'amountArg' and you're implementation in
    for variables 'name' and 'amount' respectively
    argsIn ['someArgVarName'] = 'Hello '.
    argsIn ['someBpmObject'] = myBpmObject

    2. check your other settings in logic.

    Instance.Create (processId: "/" + idOfProcess, arguments: argsIn, argumentsSetName: "BeginIn")

    The processId parameter is the thing I most often used to screw up with that. This is the text that you see when you process in the project right-click browser tab-> "Properties". Look at the value in the field 'Id' and not the field 'Name' (the name without a space). Prefix with "/" as presented here and if you have deployed this using a unit of Organization (UO) then prefix this chain also.

    The third parameter is almost always "BeginIn". Start of activities in a process can have several incoming argument mappings, the default value is "BeginIn". See your, double-click the process Begin activity and seek on behalf of mapping in the upper left corner of the dialog box.

    "argsIn" is the set of variables of incoming arguments you want to spent in the process. A common error is to type the names of the variables argument entering without the double quotes, as follows:

    . . .
    This will * NOT * work
    argsIn [someArgVarName] = 'Hello '.
    argsIn [someBpmObject] = myBpmObject
    . . .

    Here is the correct syntax:

    . . .
    This * WILL * work
    argsIn ['someArgVarName'] = 'Hello '.
    argsIn ['someBpmObject'] = myBpmObject
    . . .

    In this example, the process has two argument variables. It doesn't matter if the incoming arguments are arguments of primitive type (e.g. String, Integer, Decimal...) or objects of BPM, it is always in the same way.  In this example, there is an incoming string argument, called "someArgVarName" and an argument entering BPM object called "someBpmObject".

    Dan

  • How can I create a new instance on unix

    Hello
    How can I create a new instance (instance only) on UNIX and how do I mount my database with this new instance.

    udayjampani wrote:
    Hello
    How can I create a new instance (instance only) on UNIX and how do I mount my database with this new instance.

    (1) define the Instance in your own way!
    If you simply create a startup nomount with her, and then - in theory - and pfile file you have a conduct of the proceeding (this method is used for example for restoring a backup rman)

    (2) you can't. The database files are related to a certain instance. What you can do is to recreate an instance with a different name for example, by using the scripts generated by an "alter database backup controlfile to trace;" command

    See you soon
    FJFranken

  • create a new instance

    Hi it is Mary, I m using JavaScript in live Cycle Designer ES2 ver 9

    I m using a subform within a subform inside the content of the form

    SubForm1._Subform2.CreateInstance (True)

    It does not work for me...

    How can I create a new instance of object in it...

    Hello

    The container that the subform is inside, must be set to flowed so you can set the subform be repeatable (object > range of liaison) and allow the object > range of paging. Generally, the page is set to flowed and inside the page you placed the subforms for objects that do not develop (for example, buttons, the dates, the textfields that don't develop in height, etc.) and sank for objects that are growing, the subforms.

    Yes, your file must be saved in a dynamic XML file.

    Hope that helps,

    Niall

  • Create a new instance based on a string

    Hi all

    I have to add some movieclips dynamically to the scene. I have stockings fall on the scene who will control what is added. The value of each selection is the name of each movieclip. How can I take this and create a new instance of the clip right?

    I know that this code does not work but it needs to illustrate what I'm doing.

    var myclip:MovieClip = new dropdown1.value;

    I did some research, but so far have not had much luck. I found getChildByName, but it sounds like it just is something already on the scene.

    also, is there a way I can cite the instance dynamically so? for example, lets say I wind up adding 10 movieclips can I dynamically name myClip1, myClip2, myClip3... myClip10 - I thought I found an answer for this part by:

    var this [dropdown.text + '1']: MovieClip = new MovieClip(); but which generates an error.

    Thank you

    This is the function that I use to create new movieclip

    public static void CreateNewMovieClipByName(aStrMovieClipName:String):void

    {

    var classMovieClip: Class = ApplicationDomain.currentDomain.getDefinition (aStrMovieClipName) in class;
    return new classMovieClip();

    }

    You must ensure that the links and properties are set correctly, otherwise you won't be able to find the definition. Make sure that the correct flash files are imported.

  • Edited text symbol does not appear when I create a new instance

    I just edited the text within a symbol. But when I drag this symbol on the canvas to create a new instance, it does not reflect the changes that I made. Is this a bug or I do something wrong?

    Use the symbol properties panel to make changes to the text label.

    h

  • Cannot create a new instance in Hyperion Conf Utility

    Hello
    I installed 9.3.1 on XP Prof. planning everything is configured correctly, with the exception of the instance. I'm trying to create a new instance and system gives the following-
    "System failure: Error retrieving the xml database.

    I have re-installed and configured planning triple check that the error is not on the side of the installation.
    Guru, please provide your ideas on this. If the instance is created, I can start working on applications...

    Thanks for your time,
    Varma.

    Hello

    It should not question it is null, because an instance has not been created yet, although she always does try and access the table to see if there is something in the xml_field, the problem seems to be to try to access to this.

    Is it possible, you can raise through the planning on the windows 2003 installation configuration, one step at a time in the following order.

    Unregister the SSP.

    Product options

    Register with Shared Services

    Configure the database (when prompted, choose Remove all tables and create a new database)

    Deploy to the application server

    Instance of product registration

    See you soon

    John

    http://John-Goodwin.blogspot.com/

  • Why should I create a new user profile when you remove a damaged user account?

    I have a corrupted user account and was referred to the following link http://windows.microsoft.com/en-CA/windows-vista/Fix-a-corrupted-user-profile

    However, I don't understand why we're required to go through this complicated process when we go to Control Panel - user accounts and family safety-user accounts - add and remove accounts delete user accounts until you can actually remove an account asks you if you want to keep the files of this account.  It is said that it can automatically save the contents of this user account office and favorite Documents, music, photos and videos in a new folder on the desktop.  I realize, this does not include e-mail messages, but I thought I could export those to a memory stick and then import them into my new user account.  It all seems a much simpler process than to create a new profile.  Why Microsoft suggests must create a new profile?

    Hello Kodika

    Thanks for the return of the response.  I guess that it was just a typo, but it's OK.  Please let us know if you have any other questions or you are experiencing other problems.

    Thanks again!

  • Launch BTF in a new window via URL - always creates a new instance of the AOS?

    Hello

    JDeveloper/ADF 11.1.2.4

    I use the method documented by Frank Nimphius to open a workflow bounded in a new window. The difference in my case is rather than a range of remote data control, I want the new window to share the same instance of module app launch window.

    My BTF has Transaction < controller Transaction No. > the value and scope of data control is a shared value.

    When I run the first page (in the unlimited workflow), a new instance of AOS is created as expected.

    When I click on the button to launch the window with the stubborn workflow, another instance of AOS is created.

    The problem is that in the request module original I stored some status information in the user session data (and I coded the passivation/activate process to handle this). Unfortunately, the second instance of AOS has no access to these data. User session data is empty and no activation process is triggered to complete.

    I can use the Andrejus Baranovskis method to inject the session data in the new instance AM using a custom control of Data Factory, but it seems unnecessary to instantiate the second AM when the first could be reused.

    Is it possible I can configure the system to share the app between two windows module? If you start a BTF via a URL will be always instantiate a new App Module, regardless of the settings of transaction?

    Thank you very much

    Kevin

    Hello

    I connected an SR for this and the answer is that this is normal. A new window will always cause a new instance of AOS to create.

    See you soon,.

    Kevin

  • Create a new instance of subform on click of a button

    I need a new instance of the subform:

    assessment. Page3.standards.Standardsdetail

    be created when you click on this button:

    assessment. Page3.addanotherstandard.button1

    I tried this code on the button:

    () xfa.form.assessment.Page3.Standards.Standardsdetail.addInstance

    true );

    but it does not work.

    I am a beginner and I'm learning how to do all this with the help of the book create dynamic with Adobe LiveCycle Designer Forms but I can't seem to understand this one.

    In the subform which is supposed to be repeat you must indicate that you will allow more than one. Click the subform in the hierarchy, and then click the object/link tab, click the box that says subform repeat for each data item.

    Paul

  • creating a new instance of database - how to choose UTF-8 enconding?

    Hello again,

    How can I set the UTF-8 encoding for the new instance of the database?


    concerning

    Simply specify in the CREATE DATABASE statement:

    CHARACTER SET AL32UTF8
    

    Oracle recommends using AL32UTF8 instead of UTF8.
    Chapter 2 of the Guide to globalization:

    >
    At the top of the list of character sets that oracle recommends to all new system deployment is the AL32UTF8 defined Unicode character.
    >

    Note that the character set is a property of the database (because it defines the storage of characters) and not an instance property.

    Edited by: P. Forstmann on October 6, 2009 10:22

  • Why Thunderbird is "create a new account to get Satisfaction" when I want to ask a question

    I know I'm bad place talk about Thunderbird, but Mozilla is a name that I trust.
    When I want to ask a question in the site of Thunderbird, I had to make new account when I tried to post the question he is asked to make another account or use Yahoo, Facebook, Twitter.

    Because of this kind of fraud and fake everything, I started using the security of Mozilla products, but it seems I was mistaken.

    Just clarify why two accounts are required to ask a question?

    Thank you

    Currently support.mozilla.org is not a Thunderbird help section. Firefox, Firefox for Android, OS of Firefox and Webmaker are under the banner of support.mozilla.org .

    It has support for Thunderbird, as 2007 or 2008 Web site.

    https://support.mozillamessaging.com/en-us/home

    I don't use Thunderbird myself and I never did support in his favor, so I can't answer your question on GetSatisfaction. But I know that Mozilla has used GetSatifaction for the Firefox support in the past and is currently using "social media" for the support to the army of the great campaign.

    As far as having to register at MozillaMessaging, none of the areas Mozilla share registration information. Addons.Mozilla.Org, the Addons Support forum, Bugzilla, SUMOand quality all require a separate registration and login. Mozilla Persona will unify this process in the near future.

    Another Thunderbird support forum is here.
    http://forums.mozillazine.org/viewforum.php?f=39
    MozillaZine for a date back to the time where the Mozilla Foundation was founded and served the semi - "official support" for one for all Mozilla programs until this current SUMO forum started.

    Many users of Firefox, SeaMonkey and Thunderbird long still use MozillaZine for any help or assistance there.

  • Create a new instance of a control in qml?

    I want to add a button to a container when you press another button.

    How to create the button? create does not work, nor does the new button.

    Is this possible?

    There is no dynamic creation in QML.

    However you can create the container with the key then just hide with visibility or opacity properties and show it again when you press your button. The cookbook example is useful to show how it works.

  • Cannot create a new instance of the app after deleting older once

    Hi Experts,

    I made some changes in the form of ACF2, such as the creation of the new UDF. When I checked instance of the Application of the field were not reflected in it.
    I simply removed from the existing application instance, run suppression of post instance asks Job, scoring delete as option
    When tried to check on the cart, I get:
    No instance found application instance application 2 key


    Please help me.
    Thank you

    Make sure that you have completed "The catalog synchronization" to remove soft and follow the other task for permanent deletel

    re - visit the link to detailed below steps
    http://docs.Oracle.com/CD/E27559_01/admin.1112/e27149/appInstance.htm#CHDDBBHD

    look at Figure 8 - 4 in. above doc for deletion flow

    go through the Mode all run twice Planner position remove once mode Revoke and then in clear mode.

Maybe you are looking for

  • How to cancel the El Capitan update reboot

    Hello. I have os Maverick in my MacBook Pro mid 2012, I'm not wan't to upgrade yet because the problems of compatibility of specific software. By mistake, I hit the update button that appears in the corner of the screen from time to time. When I look

  • How to make a zoom in on part of the image using editing?

    Recently returned to the opening.  Do not remember how to enlarge the part of the image using editing.  If the answer is Loupe tool, please remind me how it works.

  • Tecra 8000 boot problem

    Hello I am new to this forum and I hope that its going to be a help. Ive had my notebook from toshiba for about three years, and I think its great. stoped to work 4 months ago and I was just it's bin but I thought it would be a waste. in any case, I

  • Triangle of translucent selection will not go away

    After a right-click for the options in any program (exel, internet exployer) selection translucent rectangle remains on the screen and disappear not except if I restart. This started happening after I had to relaod operating system and programs due t

  • Problem of not seeing list drop-down connection to the wireless network when checking connections network - pc windows 7.

    Problem of not seeing list drop-down connection to the wireless network when checking connections network - pc windows 7. I just installed a Belkin modem-router - which went well. Can I connect WiFi gadgets etc. I can also connect to the internet via