Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 268040 - Tabs are still closable despite the close button is not visible in the drop-down menu (DocumentSwitcherTable)
Tabs are still closable despite the close button is not visible in the drop-d...
Product: platform
Classification: Unclassified
Component: Window System
All All
: P1 (vote)
: Dev
Assigned To: Jiri Sedlacek
Depends on:
  Show dependency treegraph
Reported: 2016-09-15 11:20 UTC by tdr
Modified: 2017-03-10 02:55 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT


Note You need to log in before you can comment on or make changes to this bug.
Description tdr 2016-09-15 11:20:41 UTC
When using putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE) in a TopComponent, the close [x] button in the tab switcher (DocumentSwitcherTable) drop-down menu is not visible.
But when clicking on the position where the close [x] button would be displayed when enabled, the TopComponent is still closed. This is not expected.

When looking into the code of the DocumentSwitcherTable, the close button is always created.

69             btnClose = createCloseButton();

When a mouse event occurs, the click is mapped to the area of btnClose. If the click is inside this area the TopComponent is closed. There is no check if closing is allowed.

111            Dimension size = btnClose.getPreferredSize();
112            int x = rect.x+rect.width-size.width;
113            int y = rect.y + (rect.height-size.height)/2;
114            Rectangle btnRect = new Rectangle( x, y, size.width, size.height);
115            boolean inButton = btnRect.contains( p );
116            boolean mustRepaint = inCloseButtonRect != inButton;
117            inCloseButtonRect = inButton;
118            if( inButton ) {
119                if( e.getID() == MouseEvent.MOUSE_PRESSED ) {
120                    Item item = ( Item ) getModel().getValueAt( selRow, selCol );
121                    TabData tab = item.getTabData();
122                    int tabIndex = displayer.getModel().indexOf( tab );
123                    if( tabIndex >= 0 ) {
124                        TabActionEvent evt = new TabActionEvent( displayer, TabDisplayer.COMMAND_CLOSE, tabIndex);
125                        displayer.postActionEvent( evt );
126                        return true;
127                    }
128                }
129            }

Can you please add a "closing allowed" check. The needed method "isClosable" already exists.
Comment 1 tdr 2017-01-18 10:04:42 UTC
Can you please fix this bug. That would be really helpful. Thanks!
Comment 2 Jiri Sedlacek 2017-03-08 10:41:54 UTC
Fixed by
Comment 3 Quality Engineering 2017-03-10 02:55:24 UTC
Integrated into 'main-silver', will be available in build *201703100002* on (upload may still be in progress)

User: Jiri Sedlacek <>
Log: Bugfix #268040 - make sure a non-closable TopComponent cannot be closed from Document switcher

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo