<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,<br>
</p>
<p>I'm guessing you're setting the disappearing item as "Graphic",
because it is a Label and not a string. However, you can only set
a Node (anywhere, including as graphic) in one part of the scene
graph. Setting it somewhere else will cause it to be removed in
the old location (without warning unfortunately).<br>
</p>
<p>In this case, the Label is likely used as graphic in two places:
once in the list (as a cell), and once in the edit area (as
another cell) of the ComboBox when it was the last one selected.
This is causing the odd disappearing artifact.</p>
<p>Best practice is to not use Nodes as items for a ComboBox.
Instead, use a Record or some other type that the
ListCell::updateItem will convert to be shown in the way you want.<br>
</p>
<p>--John<br>
</p>
<div class="moz-cite-prefix">On 08/11/2025 22:26, Cormac Redmond
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAG_-AaBfCFLynAxwONLJOFniWEiUNjOBdnsuHQutiX2VqW=Ecw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div class="gmail_default"
style="font-family:verdana,sans-serif">Hi,</div>
<div class="gmail_quote gmail_quote_container">
<div dir="ltr">
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">There is a bug
whereby if you select a ComboBox item the item disappears
/ becomes invisible.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">This ComboBox
consists of strings and a Label node and the Label node
will disappear from the dropdown if it's selected (though,
continue to take up space).</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">I'm just picking
a Label for example, it appears to happen with any Node
that I've tried.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif"><img
src="cid:part1.aAFMHnvE.HIlb9im0@gmail.com"
alt="bug_cb.gif" class="" width="322" height="380"><br>
</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">Steps to
reproduce (JFX 26, master branch)<span
class="gmail_default"
style="font-family:verdana,sans-serif">. Note</span>:<span
class="gmail_default"
style="font-family:verdana,sans-serif"> </span>I've kept
the sample small<span class="gmail_default"
style="font-family:verdana,sans-serif"> intentionally</span>,
but if you use a CellFactory (to call setText<span
class="gmail_default"
style="font-family:verdana,sans-serif">()</span> or
setGraphic<span class="gmail_default"
style="font-family:verdana,sans-serif">()</span>
accordingly, <span class="gmail_default"
style="font-family:verdana,sans-serif">as normal), </span>the
<i><span class="gmail_default"
style="font-family:verdana,sans-serif"></span>same</i>
thing happens<span class="gmail_default"
style="font-family:verdana,sans-serif">. In other words,
the bug doesn't seem to be because of "mis-use" of the
ComboBox by mixing types -- I think</span><span
class="gmail_default"
style="font-family:verdana,sans-serif">.</span></div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div><font face="monospace">public class
ComboBoxDisappearingItemBug extends Application {<br>
public static void main(String[] args) {<br>
launch(args);<br>
}<br>
<br>
public void start(Stage stage) {<br>
ComboBox<Object> cb = new
ComboBox<>();<br>
cb.getItems().addAll("Apple", "Banana", new
Label("I will disappear"), "Carrot", "Lettuce");<br>
cb.getSelectionModel().selectFirst();<br>
stage.setScene(new Scene(cb, 200, 100));<br>
stage.show();<br>
}<br>
}</font></div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">Kind Regards,</div>
<div style="font-family:verdana,sans-serif">Cormac</div>
</div>
</div>
</div>
</blockquote>
</body>
</html>