<html><body><div class="mail_android_quote" style="line-height: 1">This is indeed a good idea. You are right, especially all the different mouse and key listener (enter, exit, pressed, drag and drop, ...) are very rarely listened to.</div><div class="mail_android_quote" style="line-height: 1"><br></div><div class="mail_android_quote" style="line-height: 1">Setting those properties will initialize the property.</div><div class="mail_android_quote" style="line-height: 1">So this complements the idea from Andy. Some properties can be more lazily initialized. While other may should not be initialized at all until someone wants to listen to it.</div><div class="mail_android_quote" style="line-height: 1"><br></div><div class="mail_android_quote" style="line-height: 1">-- Marius </div><div class="mail_android_quote" style="line-height: 1"><meta name="viewport" content="width=device-width"><meta http-equiv="Content-Type" content="text/vnd.ui.insecure+html;charset=utf-8"><div class="mail_android_quote" style="line-height: 1"><br>Am 14.02.26, 06:50 schrieb Glavo <zjx001202@<a href="http://gmail.com">gmail.com</a>>:<blockquote class="gmail_quote" style="margin: 0.8ex 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="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><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="monospace">protected final <T extends Event> EventHandler<? super T> getEventHandler(final EventType<T> eventType) {<br> getInternalEventDispatcher().getEventHandlerManager().getEventHandler(eventType);<br>}</font></blockquote><br>Then we can implement `onActionProperty()` like this:<br><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="monospace">private ObjectProperty<EventHandler<ActionEvent>> onAction;<br><br></font><font face="monospace">public EventHandler<ActionEvent> getOnAction() {<br></font><font face="monospace"> return onAction != null ? onAction.get() : (EventHandler<ActionEvent>) getEventHandler(ActionEvent.ACTION);<br></font><font face="monospace">}<br><br></font><font face="monospace">public void setOnAction(EventHandler<ActionEvent> value) {<br></font><font face="monospace"> if (onAction != null)<br></font><font face="monospace"> onAction.set(value);<br></font><font face="monospace"> else<br></font><font face="monospace"> setEventHandler(ActionEvent.ACTION, value);<br></font><font face="monospace">}<br><br></font><font face="monospace">public ObjectProperty<EventHandler<ActionEvent>> onActionProperty() {<br></font><font face="monospace"> if (onAction == null) {<br></font><font face="monospace"> onAction = new ObjectPropertyBase<>((EventHandler<ActionEvent>) getEventHandler(ActionEvent.ACTION)) {<br></font><font face="monospace"> @Override<br></font><font face="monospace"> public Object getBean() {<br></font><font face="monospace"> return ButtonBase.this;<br></font><font face="monospace"> }<br></font><font face="monospace"> @Override<br></font><font face="monospace"> public String getName() {<br></font><font face="monospace"> return "onAction";<br></font><font face="monospace"> }<br></font><font face="monospace"> @Override<br></font><font face="monospace"> protected void invalidated() {<br></font><font face="monospace"> setEventHandler(ActionEvent.ACTION, get());<br></font><font face="monospace"> }<br></font><font face="monospace"> };<br></font><font face="monospace"> }<br></font><font face="monospace"> return onAction;<br></font><font face="monospace">}</font></blockquote><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.<br><div><br></div><div>Glavo</div></div><br><div class="gmail_quote gmail_quote_container"><div class="gmail_attr" dir="ltr">On Thu, Feb 5, 2026 at 5:17 AM Andy Goryachev <<a href="mailto:andy.goryachev@oracle.com">andy.goryachev@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div 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 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)">
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 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 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 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)">
Cheers,</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)">
<b>References</b></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)">
[0] <a href="https://github.com/andy-goryachev-oracle/Test/blob/main/doc/Experiments/NodeProperties.md">
https://github.com/andy-goryachev-oracle/Test/blob/main/doc/Experiments/NodeProperties.md</a></div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
</div>
</blockquote></div>
</blockquote></div></div></body></html>