Setting graphics of a Labeled does not show the Label correctly
Nir Lisker
nlisker at gmail.com
Thu Dec 1 10:23:43 UTC 2022
Hi,
Given the following code
var cb1 = new Label("1");
var cb2 = new Label ("2");
var b1 = new Button("A");
cb1.setGraphic(b1);
b1.setOnAction(e -> {
if (b1.getParent() == cb1) {
// cb1.setGraphic(null);
cb2.setGraphic(b1);
} else {
// cb2.setGraphic(null);
cb1.setGraphic(b1);
}
});
Pressing the first button will move it (the graphic) to the second label,
however, pressing it again will not move it back to the first label. It's
required to set the graphics to null prior to moving them as in the
commented lines. This looks like a bug to me. I would think that when a
graphic is moved, it will appear in its new label immediately, like moving
a child. Apparently a single node can be the graphics for multiple Labeled
nodes, but it will appear only in 1. Is this intentional?
- Nir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20221201/1cd52163/attachment.htm>
More information about the openjfx-dev
mailing list