apache / apache/netbeans

Non-closable TopComponent still closable via middle-click button

Open
#8,501 2 comments 0 reactions 0 assignees View on GitHub
kind:bug Platform UI
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 25

### What happened

A (non-editor) TopComponent with client property `TopComponent.PROP_CLOSING_DISABLED=true` is displayed as a tab with no _close_ button and no _close_ menu entry. This is OK.

But actually it is still closable via mouse middle-click on the tab.

### Language / Project Type / NetBeans Component

Netbeans platform application

### How to reproduce

Add a TopComponent to a NB platform app.

Add `putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); `in constructor.

Run, middle-click tab name (possibly several times), TopComponent is closed.

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Win 11

### JDK

Adoptium 23

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

It seems problem comes from: https://github.com/apache/netbeans/blob/master/platform/core.windows/src/org/netbeans/core/windows/view/ui/CloseButtonTabbedPane.java, see MouseListener at the beginning.

I tried setting client property `TabbedPaneFactory.NO_CLOSE_BUTTON` to true in my TopComponent, so that `hideCloseButton()` returns true and blocks the call to `fireCloseRequest()` in `mouseReleased()`, but it did not work. I could not debug from my config so I stopped there.

I found an easy workaround by overriding `TopComponent.canClose()` to return false.

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start in platform/core.windows/src/org/netbeans/core/windows/view/ui/CloseButtonTabbedPane.java, especially the MouseListener and its mouseReleased handling. Reproduce the issue in a NetBeans Platform application with a TopComponent using PROP_CLOSING_DISABLED and middle-click the tab. Done means middle-click no longer closes that TopComponent while normal closable tabs retain their behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.