On Wed, 20 May 2026 18:36:47 GMT, Andy Goryachev <[email protected]> wrote:

>> Tries to address the mystery of missing graphic in the TabPane overflow menu.
>> 
>> ### Summary of Changes
>> 
>> - minor `TabPaneSkin` constructor javadoc clarification
>> - added the `menuGraphicOverride` property
>> - changed popup menu to be created on demand
>> - removing adding the popup reference to the `TabHeaderSkin` properties (I 
>> think it was done for testing purposes, I could not find any references to 
>> it in the code)
>>  
>> For a quick tester, use 
>> https://bugs.openjdk.org/secure/attachment/114240/TabPaneGraphicFactoryExample.java
>> 
>> # Overflow Menu Graphic Property in the TabPaneSkin
>> 
>> Andy Goryachev
>> 
>> <[email protected]>
>> 
>> 
>> ## Summary
>> 
>> Introduce a `menuGraphicOverride` property in the `TabPaneSkin` class 
>> eliminates the current limitation of this skin
>> in supporting menu item graphics other than an `ImageView` or `Label` with 
>> an `ImageView` graphic.
>> 
>> 
>> 
>> ## Goals
>> 
>> The goals of this proposal are:
>> 
>> - to allow the application developers to customize the overflow menu items' 
>> graphic
>> - retain the backward compatibility with the existing application code
>> - clarify the behavior of the skin when the property is null (i.e. the 
>> current behavior)
>> 
>> 
>> 
>> ## Non-Goals
>> 
>> The following are not the goals of this proposal:
>> 
>> - disable the overflow menu
>> - configure overflow menu graphic property via CSS
>> - add this property to the `TabPane` control itself
>> 
>> 
>> 
>> ## Motivation
>> 
>> The existing `TabPaneSkin` does not allow the overflow menu to show graphic 
>> other than
>> an `ImageView` or `Label` with an `ImageView`.
>> 
>> This limitation makes it impossible for the application developer to use 
>> other graphic Nodes,
>> such as `Path` or `Canvas`, or in fact any other types.  The situation 
>> becomes even more egregious
>> when the tabs in the `TabPane` have no text.
>> 
>> Example:
>> 
>> 
>> public class TabPaneGraphicFactoryExample {
>>     public void example() {
>>         Tab tab1 = new Tab("Tab1");
>>         tab1.setGraphic(createGraphic(tab1));
>> 
>>         Tab tab2 = new Tab("Tab2");
>>         tab2.setGraphic(createGraphic(tab2));
>> 
>>         TabPane tabPane = new TabPane();
>>         tabPane.getTabs().addAll(tab1, tab2);
>> 
>>         TabPaneSkin skin = new TabPaneSkin(tabPane);
>>         // set overflow menu factory with the same method as was used to 
>> create the tabs
>>         skin.setMenuGraphicOverride(this::createGraphic);
>>         tabPane.setSkin(skin);
>>     }
>> 
>>     // creates graphic Nodes for tabs as we...
>
> Andy Goryachev has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   override

Sorry for the delay. 

Today I set up the project I've worked on in the past (but not anymore), and 
where this feature would have been really helpful (back when I implemented 
this). 

In this case, tiles open tabs. 
Only the Home tab has an icon but no name (and shows all the tiles).
When clicking on a Tile, a Tab opens but they never have an icon, only text. 

And that's where I had the idea to simply set the menu graphic to `null` so 
there would be no icon at all, saving space entirely. At the same time, 
however, it would be useful to be able to customize the text there as well so 
that 'Home' is shown there while the Tab has no text.

<img width="1061" height="364" alt="image" 
src="https://github.com/user-attachments/assets/b9b7e61c-ff39-42c5-a400-c312683128a6";
 />

Overflow:

<img width="230" height="184" alt="image" 
src="https://github.com/user-attachments/assets/b4df3b3b-7bf3-4d4b-82f9-19fc532dc3e8";
 />

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1773#issuecomment-4660307809

Reply via email to