<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Sorry, I meant on the first click already.<br>
</p>
<p>--John<br>
</p>
<div class="moz-cite-prefix">On 01/12/2022 14:46, John Hendrikx
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:d533ff55-982a-20fb-a817-d08df1679e68@gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p>Setting the same Node for multiple graphics is not allowed.
Your program should IMHO throw "IllegalArgumentException" on the
2nd click.<br>
</p>
<p> * An optional icon for the Labeled. This can be positioned
relative to the<br>
* text by using {@link #setContentDisplay}. The node
specified for this<br>
* variable cannot appear elsewhere in the scene graph,
otherwise<br>
* the {@code IllegalArgumentException} is thrown. See the
class<br>
* description of {@link Node} for more detail.</p>
<p>--John<br>
</p>
<div class="moz-cite-prefix">On 01/12/2022 13:38, Nir Lisker
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CA+0ynh9RXamDJ4SMSrKNur83Sj28znvi5_VzimE+6CJ7ftSvjw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<div dir="ltr">That's my point. Currently, a node can serve as
the graphics property for multiple Labels, but will appear
only in 1 because it can only have a single parent in the
scenegraph. While this is technically fine, it causes issues
like the one I showed above. I'm not sure if a node is
supposed to be able to serve as multiple graphics (and
displayed only in the last Label it was set to?), or removed
from other Labels' graphic properties just like is done for
children in the scenegraph. Personally, I find it confusing
that label.getGraphics() will return a node that isn't shown
in that label.</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Dec 1, 2022 at 2:21
PM John Hendrikx <<a
href="mailto:john.hendrikx@gmail.com"
moz-do-not-send="true" class="moz-txt-link-freetext">john.hendrikx@gmail.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">Internally the graphics
is just a child node, and nodes can't be part of <br>
the scene graph twice (this is done in LabeledSkinBase).<br>
<br>
It showing up only once is probably because it is getting
removed from <br>
the other labels.<br>
<br>
I think things are probably getting out of sync, where the
graphics <br>
property may think it still has a certain node as its
graphics, but it <br>
is no longer a child of the label.<br>
<br>
--John<br>
<br>
On 01/12/2022 11:23, Nir Lisker wrote:<br>
> Hi,<br>
><br>
> Given the following code<br>
><br>
> var cb1 = new Label("1");<br>
> var cb2 = new Label ("2");<br>
> var b1 = new Button("A");<br>
> cb1.setGraphic(b1);<br>
> b1.setOnAction(e -> {<br>
> if (b1.getParent() == cb1) {<br>
> // cb1.setGraphic(null);<br>
> cb2.setGraphic(b1);<br>
> } else {<br>
> // cb2.setGraphic(null);<br>
> cb1.setGraphic(b1);<br>
> }<br>
> });<br>
><br>
> Pressing the first button will move it (the graphic) to
the second <br>
> label, however, pressing it again will not move it back
to the first <br>
> label. It's required to set the graphics to null prior
to moving them <br>
> as in the commented lines. This looks like a bug to me.
I would think <br>
> that when a graphic is moved, it will appear in its new
label <br>
> immediately, like moving a child. Apparently a single
node can be the <br>
> graphics for multiple Labeled nodes, but it will appear
only in 1. Is <br>
> this intentional?<br>
><br>
> - Nir<br>
</blockquote>
</div>
</blockquote>
</blockquote>
</body>
</html>