<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif"><div class="gmail_default">Hi Andy,</div><div class="gmail_default"><br></div><div class="gmail_default">Thank you for your reply. </div><div class="gmail_default"><br></div><div class="gmail_default">That sounds good, re: a menu item factory. E.g., give the devs full control.</div><div class="gmail_default"><br></div><div class="gmail_default">I think the ability to disable it (or have it disabled by default) would be good too: a dev might not <i>care</i> about supporting the menu items in many cases. E.g., if a TabPane only has three (graphic-based) tabs, and the user decides to resize the window to something unusually small, then who cares if they can't traverse the tabs, at that size? Nobody realistically expects to be able in such a scenario anyway, and it's better to have no menu than a buggy one. </div><div class="gmail_default"><br></div><div class="gmail_default">I don't like the fact that, today, TabPane's menu can misbehave and nobody would know it's going to happen really. I think TabPane should throw an exception (or log a warning) when it receives nodes it knows it will not be able to use in the menu; especially given the menu is always-on.</div><div class="gmail_default"><br></div><div class="gmail_default">I think a good overall solution would be:</div><div class="gmail_default"><ol><li style="margin-left:15px">a menu factory</li><li style="margin-left:15px">make the menu optional for those who don't care</li><li style="margin-left:15px">log warnings when a tab's header node will not be displayable in a menu (i.e., if the dev hasn't provided a factory and the default "menu factory" knowingly cannot handle it)</li><ol><li style="margin-left:15px">Not really sure how JFX folks feel about logging warnings, I note it's minimal today in general, and probably for good reason (e.g., where do you draw the line in the sand about what should be logged vs. not)</li></ol></ol></div><div class="gmail_default">Anyway, I think the above will be achievable without any breaking / functionality changes...?</div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default">Kind Regards,</div><div class="gmail_default">Cormac</div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, 7 Apr 2025 at 17:59, 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 class="msg-5619657704761886284">





<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="m_-5619657704761886284WordSection1">
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">All very good points, thank you for this writeup!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">This discussion relates to
<a href="https://bugs.openjdk.org/browse/JDK-8353599" target="_blank">https://bugs.openjdk.org/browse/JDK-8353599</a> .  I've been thinking how to handle this issue, and I am leaning to agree with the suggestion proposed in the ticket (some sort of menu item factory).<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">The current "hacky" solution not obviously fails, but also not scalable - I can see developers wanting to place a Canvas, a Path, a Pane, or any other kind of Node and it would
 be nearly impossible to "clone" these in a maintainable manner.  With a menu item factory, however, the effort will be shifted on the application dev with a very simple solution.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">The other solution that does not involve a new API would be to limit the overflow menu to only list the tabs that are hidden - in this case the graphics Nodes can be reused
 by the menu items.  The problem with that approach is the overflow menu logic becomes more complicated, to handle the case when menus are hidden on both ends.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">What do you think?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16"">-andy<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:"Iosevka Fixed SS16""><u></u> <u></u></span></p>
<div id="m_-5619657704761886284mail-editor-reference-message-container">
<div>
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(181,196,223);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">openjfx-dev <<a href="mailto:openjfx-dev-retn@openjdk.org" target="_blank">openjfx-dev-retn@openjdk.org</a>> on behalf of Cormac Redmond <<a href="mailto:credmond@certak.com" target="_blank">credmond@certak.com</a>><br>
<b>Date: </b>Friday, April 4, 2025 at 17:00<br>
<b>To: </b><a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a> <<a href="mailto:openjfx-dev@openjdk.org" target="_blank">openjfx-dev@openjdk.org</a>><br>
<b>Subject: </b>TabPane overflow menu showing blanks<u></u><u></u></span></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">Hi,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">TabPane tabs allow you to set graphic nodes as the header and there appears to be no documented limitations or best-practises on this.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">You might assume it's perfectly reasonable to not set a Tab's text value, and instead set the header as a HBox, consisting of a graphic node (left) and a Label
 (itself with a text + a graphic, right), to achieve an icon-text-icon style header, which is not an uncommon. <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">However, the overflow menu, when it kicks in, will not display any text or graphics at all (just a blank space), if your Tab has no "text" set, and the header graphic
 is not a Label or an ImageView.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">It's down to this self-confessed hacky code (<a href="https://github.com/openjdk/jfx/blob/f31d00d8f7e601c3bb28a9975dd029390ec92173/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TabPaneSkin.java#L479" target="_blank">https://github.com/openjdk/jfx/blob/f31d00d8f7e601c3bb28a9975dd029390ec92173/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TabPaneSkin.java#L479</a>):<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New";color:black">    /**<br>
     * VERY HACKY - this lets us 'duplicate' Label and ImageView nodes to be used in a<br>
     * Tab and the tabs menu at the same time.<br>
     */<br>
    private static Node clone(Node n) {<br>
        if (n == null) {<br>
            return null;<br>
        }<br>
        if (n instanceof ImageView) {<br>
            ImageView iv = (ImageView) n;<br>
            ImageView imageview = new ImageView();<br>
            imageview.imageProperty().bind(iv.imageProperty());<br>
            return imageview;<br>
        }<br>
        if (n instanceof Label) {<br>
            Label l = (Label)n;<br>
            Label label = new Label(l.getText(), clone(l.getGraphic()));<br>
            label.textProperty().bind(l.textProperty());<br>
            return label;<br>
        }<br>
        return null;<br>
    }</span><span style="font-size:12pt;color:black"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">It is not obvious at all that this is what's going to happen, or why. And it seems impossible to control or influence this in any reasonable way, without replacing
 the whole TabPaneSkin.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">Given TabPane is one of the most important and widely used controls there is, there could/should be some of the following:<u></u><u></u></span></p>
</div>
<div>
<ul type="disc">
<li class="MsoNormal" style="color:black">
<span style="font-size:12pt;font-family:Verdana,sans-serif">Proper documentation on this limitation / behaviour<u></u><u></u></span></li><li class="MsoNormal" style="color:black">
<span style="font-size:12pt;font-family:Verdana,sans-serif">Some way to set fallback text that can be used in the menu (i.e., that isn't the Tab's header's text, because one might intentionally avoid setting that given there's no way to hide it from the
 tab header) <u></u><u></u></span></li><li class="MsoNormal" style="color:black">
<span style="font-size:12pt;font-family:Verdana,sans-serif">Or, better yet, some way to allow you to specify tab header text without displaying it in the actual tab header, which could then be used by the hacky method as normal<u></u><u></u></span></li><li class="MsoNormal" style="color:black">
<span style="font-size:12pt;font-family:Verdana,sans-serif">Some way to set a callback so the developer can decide what gets displayed for the overflow menu<u></u><u></u></span></li><li class="MsoNormal" style="color:black">
<span style="font-size:12pt;font-family:Verdana,sans-serif">Some way to override the skin without needing a full copy + paste + rename<u></u><u></u></span></li><li class="MsoNormal" style="color:black">
<span style="font-size:12pt;font-family:Verdana,sans-serif">Some way to allow the dev to disable the overflow menu, if it's going to produce something unusable. E.g., prefer no menu than a buggy one...<u></u><u></u></span></li></ul>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">I would view this as a bug, even though it's probably been like this forever.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">Some sample code to demonstrate; just look at the menu:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;color:black"><br>
</span><span style="font-size:12pt;font-family:"Courier New";color:black">public class TabPaneMenu extends Application {<br>
    @Override<br>
    public void start(Stage primaryStage) {<br>
        TabPane tabPane = new TabPane();<br>
<br>
        for (int i = 1; i <= 30; i++) {<br>
            Tab tab;<br>
            if (i == 2) {<br>
                tab = new Tab();<br>
                final Label label = new Label("HBox Tab " + i);<br>
                final HBox hBox = new HBox(label); // Will show as blank in overflow menu!<br>
                tab.setGraphic(hBox);<br>
            } else if (i == 5) {<br>
                tab = new Tab();<br>
                tab.setGraphic(new Label("Label Tab " + i)); // Will show in overflow menu, because it's a Label<br>
            } else {<br>
                tab = new Tab("Normal Tab " + i);<br>
            }<br>
<br>
            tab.setContent(new StackPane(new Label("This is Tab " + i)));<br>
            tab.setClosable(false);<br>
            tabPane.getTabs().add(tab);<br>
<br>
        }<br>
<br>
        Scene scene = new Scene(tabPane, 800, 600);<br>
        primaryStage.setScene(scene);<br>
        primaryStage.show();<br>
    }<br>
<br>
    public static void main(String[] args) {<br>
        launch(args);<br>
    }<br>
}</span><span style="font-size:12pt;color:black"><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:12pt"><br clear="all">
<u></u><u></u></span></p>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span class="m_-5619657704761886284gmaildefault"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">Kind </span></span><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">Regards,</span><span style="font-size:12pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<p class="MsoNormal"><b><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">Cormac Redmond</span></b><span style="font-size:12pt"><u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:Verdana,sans-serif;color:black">Software Engineer, Certak Ltd.</span><span style="font-size:12pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:Verdana,sans-serif">e: <a href="mailto:credmond@certak.com" target="_blank">
credmond@certak.com</a> | m: +353 (0) 86 268 2152 | w: <a href="http://www.certak.com" target="_blank">
www.certak.com</a></span><span style="font-size:12pt"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</div></blockquote></div>