<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Hi John,</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Thanks for the reply & details. One remaining question in my previous mail however, was why a max <b>needs</b> to be set for min to "win"...this still didn't make sense.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Similarly, I had already tried prefHeight on its own, but it has no effect (unless it's set to number higher than the computed size of the cell, in which case it would increase the size). Setting prefHeight and minHeight together though, can achieve setting a "max height" though, just like setting a maxHeight and minHeight as per my previous mail.</div><div class="gmail_default" style="font-family:verdana,sans-serif"><div class="gmail_default"><br></div><div class="gmail_default">But I've noticed that values prefHeight, minHeight, maxHeight are all defaulted to USE_COMPUTED_SIZE (-1)..., <b>not USE_PREF_SIZE</b> as you mentioned, and I assumed.</div><div class="gmail_default"><br></div><div class="gmail_default">So this explains the above behaviour and why several need to be set: otherwise computed size wins one way or another.</div></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Although confusing initially, I assume there's no bug here and that the developer needs to always check the underlying nature of how pref/min/max default values are set for any node, in order to know what and how to override their settings...?</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">If you want some validation, you can see these -1 defaults, via a simpler example:</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style=""><font face="monospace" size="1">public class ComboBoxHeightBug2 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", "Carrot", "Lettuce");<br> cb.setCellFactory(_ -> new ListCell<>() {<br> protected void updateItem(Object item, boolean empty) {<br> super.updateItem(item, empty);<br> if (empty || item == null) {<br> setText(null);<br> setGraphic(null);<br> } else if (item instanceof Separator) {<br> setText(null);<br> setGraphic((Separator) item);<br> setDisable(true);<br> } else {<br> System.out.println("minHeight: " + getMinHeight()); // -1<br> System.out.println("maxHeight: " + getMaxHeight()); // -1<br> System.out.println("prefHeight: " + getPrefHeight()); // -1<br> setText(item.toString());<br> setGraphic(null);<br> setStyle("");<br> }<br> }<br> });<br><br> cb.getSelectionModel().selectFirst();<br> stage.setScene(new Scene(cb, 200, 100));<br> stage.show();<br> }<br>}</font></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Kind Regards,</div><div class="gmail_default" style="font-family:verdana,sans-serif">Cormac</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 9 Nov 2025 at 00:06, John Hendrikx <<a href="mailto:john.hendrikx@gmail.com" target="_blank">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"><u></u>
<div>
<p>What you are likely seeing is that the minimum always wins over
the other values.</p>
<p>The minimum height is set to the constant <span class="gmail_default" style="font-family:verdana,sans-serif"></span>USE_PREF_SIZE, which
means that it will take the preferred size for the minimum height.</p>
<p>When it comes to size priorities (min, pref and max), minimum
always wins, then comes maximum, then comes preferred.</p>
<p>So in this case, the preferred size is say 20. The minimum
follows the preferred, also 20. You set maximum to 1. Minimum
> Maximum, so Maximum is ignored.</p>
<p>What you could try is set preferred size smaller instead; there
should be no need to change minimum or maximum then.</p>
<p>--John<br>
</p>
<div>On 08/11/2025 21:30, Cormac Redmond
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div style="font-family:verdana,sans-serif">Hi,</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">I have found a height
bug when I am trying to reduce the height of one ComboBox item
(a Separator) in a simple ComboBox.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">One would expect that
to achieve this, you'd set the maximum height for that
particular ListCell; but this has no effect.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">Instead what I need to
do is set the <i>minimum</i> height (but to the value I wish
to be the maximum height), and I must <b>also </b>set the <i>maximum
</i>height to any value (if I do not, my minimum height (i.e.,
my desired maximum) gets ignored)...</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">For example, if I want
the maximum height of this Separator to be 6, I must set the
minimum height to 6 and I must set the maximum height to
anything, even 1.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">Obviously this is
counter-intuitive and doesn't make any logical sense.</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div style="font-family:verdana,sans-serif">Example to reproduce
(running from JFX master branch):</div>
<div style="font-family:verdana,sans-serif"><br>
</div>
<div><font face="monospace"><span class="gmail_default" style="font-family:verdana,sans-serif"></span>public
class ComboBoxHeightBug 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", </font>
<span style="font-family:monospace">new Separator()</span> <font face="monospace">, "Carrot", "Lettuce");<br>
cb.setCellFactory(_ -> new ListCell<>() {<br>
protected void updateItem(Object item, boolean
empty) {<br>
super.updateItem(item, empty);<br>
if (empty || item == null) {<br>
setText(null);<br>
setGraphic(null);<br>
setStyle("");<br>
</font><span style="font-family:monospace">
// Set back to default</span><br style="font-family:monospace">
<font face="monospace">
setMinHeight(USE_PREF_SIZE);<br>
setMaxHeight(Double.MAX_VALUE);<br>
} else if (item instanceof Separator) {<br>
setText(null);<br>
setGraphic((Separator) item);<br>
setDisable(true);<br>
setMinHeight(6); // This is required for
any "max height" to apply, and appears to be the value that
is used to determine height<br>
setMaxHeight(1); // Setting this (to 6)
should work on its own, it doesn't, the value appears
irrelevant -- but it MUST be set to get the separator height
to be 6<br>
} else {<br>
setText(item.toString());<br>
setGraphic(null);<br>
setStyle("");<br>
// Set back to default<br>
setMinHeight(USE_PREF_SIZE);<br>
setMaxHeight(Double.MAX_VALUE);<br>
}<br>
}<br>
});<br>
<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">Note: I have noticed a
few issues like this in general, whereby it requires trial and
error to get <i>some</i> desired height to apply; without any
apparent logic as to how these values are being arrived at or
how they're triggered to be used (I have logged bugs before on
this)...</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>
</blockquote>
</div>
</blockquote></div></div>
</div>