This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 240810

Summary: TabbedContainer and BasicTabDisplayerUI should support hiding of "Close" button for non TopComponent
Product: platform Reporter: jmborer <jmborer>
Component: Window SystemAssignee: Stanislav Aubrecht <saubrecht>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 7.4   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:

Description jmborer 2014-01-22 10:30:28 UTC
When you use a TabbedContainer, it is not possible to disable(hide) the close button for other components than TopComponents.

TabbedContainer is a very useful component and should be improved to be used inside TopComponents for example for sub tabs.

Currently the implementation of BasicTabDisplayerUI does allow that. In method getTabCellRendere:

    public TabCellRenderer getTabCellRenderer(int tab) {
        defaultRenderer.setShowCloseButton(displayer.isShowCloseButton());
        if( tab >=0 && tab < displayer.getModel().size() ) {
            TabData data = displayer.getModel().getTab(tab);
            boolean closingEnabled = true;
            if( data.getComponent() instanceof TopComponent ) {
                closingEnabled = displayer.getContainerWinsysInfo().isTopComponentClosingEnabled( (TopComponent)data.getComponent() );
            }

            defaultRenderer.setShowCloseButton(displayer.isShowCloseButton() && closingEnabled);
        }
        return defaultRenderer;
    }

it is possible to hide the close button only if the component is a TopComponent even though you provide pour own implementation of WinsysInfoForTabbed.

One option would be to add (or replace isTopComponentClosingEnabled) a new method to WinsysInfoForTabbed named isClosingEnabled(Component comp) and then remove the "data.getComponent() instanceof TopComponent" test.
Comment 1 Stanislav Aubrecht 2014-01-22 11:34:22 UTC
Why don't you use TabDisplayer.setShowCloseButton(false)? Or do you need to suppress close button for a single tab only?
Comment 2 jmborer 2014-01-22 12:47:24 UTC
I need to hide the button for a single tab, that always remains at position 0. OK, you might argue that my HMI is bad. Well, possible. Meanwhile having one fixed tab and other dynamic a closeable beside it, is very easy to understand for the end user and saves a lot of space.
Comment 3 jmborer 2014-01-22 12:53:37 UTC
So what I did meanwhile is make my "non-closeable" component extend TopComponent and provide my own WinsysInfoForTabbed which checks for client property TopComponent.PROP_CLOSING_DISABLED.

It works, but I don't really know if there are side effects of using TopComponents inside other TopComponents and outside the windowing system of Netbeans.

I know that there is TabbedPaneFactory.createCloseButtonTabbedPane(), but aside that TabbedContainer has a "greater" implementation for handling a lot of tabs, I appreciate TabbedContainer's default behaviors like, "close all" or "close all but me" features, that doesn't exist with TabbedPaneFactory.

I don't know if there are better technics or APIs I could use.