<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Yes, you went a step beyond - by including the subclasses and, as a necessity, adding a public API (a protected method).  I think you also went further by avoiding the property instantiation in the setter if it's not needed, if I read the code correctly.</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I would advocate against creating public APIs (by using Accessor pattern) for subclasses.  The trick of avoiding instantiation is probably not needed for event handler properties (it's unlikely the application would set the handler to null), but it makes sense
 for other properties that take a Boolean or a simple value.  In these cases, the setter might avoid creating the property if the value being set equals to the default value.</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
In other words, we can probably save even more memory once we go beyond the Node class and smarter setters.</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
-andy</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="mail-editor-reference-message-container">
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="text-align: left; padding: 3pt 0in 0in; border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor; font-family: Aptos; font-size: 12pt; color: black;">
<b>From: </b>Glavo <zjx001202@gmail.com><br>
<b>Date: </b>Saturday, February 14, 2026 at 09:47<br>
<b>To: </b>Andy Goryachev <andy.goryachev@oracle.com><br>
<b>Cc: </b>OpenJFX <openjfx-dev@openjdk.org><br>
<b>Subject: </b>[External] : Re: Experiment: Node properties<br>
<br>
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
This is the prototype implementation of my idea: <a href="https://urldefense.com/v3/__https://github.com/Glavo/jfx/tree/event-handler-properties__;!!ACWV5N9M2RV99hQ!JYrjeh4cs83mjhiReeU80iO4mWqRgsGzePVdGcbVvtB2kkfolK6Gs2vC2ankqr0Ebmw-9bANAvHp4l2BzZ83Bm8$" data-outlook-id="df9c7c0b-f9d1-40bb-a9c3-48c30bb3fe0d">
https://github.com/Glavo/jfx/tree/event-handler-properties</a></div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
<br>
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
For all event handler properties, it will eliminate the need to construct these properties if the user only uses the set methods (`setOnAction`/`setOnMousePressed`/...) </div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
and does not directly call the property getter methods (`onActionProperty`/`onMousePressedProperty`/...).</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
<br>
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
Currently, I use HashMap to store the properties in Node, but it can also be easily replaced with Andy's FastMap.</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
<br>
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
I'm not sure if this idea is worth investing more effort in, so I'd like to ask for everyone's opinion.</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
<br>
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
Glavo</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
<br>
</div>
<div class="gmail_attr" style="direction: ltr;">On Sat, Feb 14, 2026 at 1:46 PM Glavo <<a href="mailto:zjx001202@gmail.com" data-outlook-id="98c013ab-14fc-411f-99b4-0eb769d12407">zjx001202@gmail.com</a>> wrote:</div>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204);">
<div class="gmail_quote" style="direction: ltr;">I have another idea: event handle properties (like `ButtonBase#onActionProperty()`) are frequently set, but rarely have listeners added.<br>
I think we can initialize these properties more lazily.<br>
<br>
We can add the following method to `Node`:<br>
<br>
</div>
<div class="gmail_quote" style="direction: ltr; margin: 0px 0px 0px 40px; border-width: medium; border-style: none; border-color: currentcolor; font-family: monospace;">
protected final <T extends Event> EventHandler<? super T> getEventHandler(final EventType<T> eventType) {<br>
    getInternalEventDispatcher().getEventHandlerManager().getEventHandler(eventType);<br>
}</div>
<div class="gmail_quote" style="direction: ltr;"><br>
Then we can implement `onActionProperty()` like this:<br>
<br>
</div>
<div class="gmail_quote" style="direction: ltr; margin: 0px 0px 0px 40px; border-width: medium; border-style: none; border-color: currentcolor; font-family: monospace;">
private ObjectProperty<EventHandler<ActionEvent>> onAction;<br>
<br>
public EventHandler<ActionEvent> getOnAction() {<br>
    return onAction != null ? onAction.get() : (EventHandler<ActionEvent>) getEventHandler(ActionEvent.ACTION);<br>
}<br>
<br>
public void setOnAction(EventHandler<ActionEvent> value) {<br>
    if (onAction != null)<br>
        onAction.set(value);<br>
    else<br>
        setEventHandler(ActionEvent.ACTION, value);<br>
}<br>
<br>
public ObjectProperty<EventHandler<ActionEvent>> onActionProperty() {<br>
    if (onAction == null) {<br>
        onAction = new ObjectPropertyBase<>((EventHandler<ActionEvent>) getEventHandler(ActionEvent.ACTION)) {<br>
            @Override<br>
            public Object getBean() {<br>
                return ButtonBase.this;<br>
            }<br>
            @Override<br>
            public String getName() {<br>
                return "onAction";<br>
            }<br>
            @Override<br>
            protected void invalidated() {<br>
                setEventHandler(ActionEvent.ACTION, get());<br>
            }<br>
        };<br>
    }<br>
    return onAction;<br>
}</div>
<div class="gmail_quote" style="direction: ltr;"><br>
This allows us to eliminate the allocation of many properties.<br>
Although there is a slight risk (the behavior will change slightly if the user updates the handler value with `setEventHandler(ActionEvent.ACTION, ...)` before calling `onActionProperty()`/`getOnAction()`), I think it is worthwhile.</div>
<div class="gmail_quote" style="direction: ltr;"><br>
</div>
<div class="gmail_quote" style="direction: ltr;">Glavo</div>
<div class="gmail_quote" style="direction: ltr;"><br>
</div>
<div class="gmail_attr" style="direction: ltr;">On Thu, Feb 5, 2026 at 5:17 AM Andy Goryachev <<a href="mailto:andy.goryachev@oracle.com" target="_blank" data-outlook-id="894bb5f0-ee1d-42db-9e95-f30d1f92d11d">andy.goryachev@oracle.com</a>> wrote:</div>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204);">
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I would like to share the results of a little experiment involving optimization of storage of Node properties.  The basic idea is to create a compact fast map-like container to hold the rarely instantiated properties in order to reduce the application memory
 footprint.</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The savings are not overwhelming, but not exactly zero.  I would imagine this optimization might be more interesting in any resource constrained environment such as Android / iOS / RaspberryPi.  Please refer to [0] for the details.</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I encourage you to try it with your application, to see whether you notice any change in memory consumption and/or performance.  Let me know what you think!</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Cheers,</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
-andy</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>References</b></div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
[0] <a href="https://urldefense.com/v3/__https://github.com/andy-goryachev-oracle/Test/blob/main/doc/Experiments/NodeProperties.md__;!!ACWV5N9M2RV99hQ!JYrjeh4cs83mjhiReeU80iO4mWqRgsGzePVdGcbVvtB2kkfolK6Gs2vC2ankqr0Ebmw-9bANAvHp4l2BRfQIOQs$" target="_blank" data-outlook-id="aeff9ec6-5ad2-4dbc-85b7-9ee3be620a76">
https://github.com/andy-goryachev-oracle/Test/blob/main/doc/Experiments/NodeProperties.md</a></div>
<div class="gmail_quote" style="direction: ltr; font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt;">
<br>
</div>
</blockquote>
</blockquote>
</div>
</body>
</html>