Customizable Table Button Menu

Andy Goryachev andy.goryachev at oracle.com
Tue May 16 16:36:39 UTC 2023


This looks to me like a good solution, with a rather small probability of breaking the existing application code.

-andy



From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of Marius Hanl <mariushanl at web.de>
Date: Monday, May 15, 2023 at 15:05
To: openjfx-dev <openjfx-dev at openjdk.org>
Subject: Customizable Table Button Menu
In https://github.com/openjdk/jfx/pull/1135 I implemented a way to override the behaviour when the table menu button is clicked.

Current behaviour
The table menu button is visible when setTableMenuButtonVisible(true) is called.
When clicked, a ContextMenu is shown with all available columns of the table shown as MenuItem.
A user can then click on a MenuItem to make the corresponding column (in)visible and the ContextMenu closes afterwards.

Problems
This comes with some limitations as described here https://bugs.openjdk.org/browse/JDK-8091419, here https://bugs.openjdk.org/browse/JDK-8091153 and here https://bugs.openjdk.org/browse/JDK-8092148.
In short:
- It is not always desired that the ContextMenu closes after the user clicked on a MenuItem. This is a limitation of the ContextMenu
- The menu can not be invoked programmatically
- The menu can not overridden in any way

Solution
To address these issues, the PR mentioned above adds a new protected method showColumnMenu(MouseEvent) which is called when the table menu button is clicked.
Since this new method is protected, it can be overidden by developers. If not overridden, the known default ContextMenu is created and shown, as described above.

This gives every developer the ability to fully customize the behaviour when the table menu button is clicked.
A developer can implement their own Menu if the behaviour of the ContextMenu is not desired.
The method can now also be invoked programmatically.

Feel free to give Feedback and/or checkout the PR.

-- Marius

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20230516/a5d03d9a/attachment-0001.htm>


More information about the openjfx-dev mailing list