mgarin / weblaf

WebLaF is a fully open-source Look & Feel and component library written in pure Java for cross-platform desktop Swing applications.
http://weblookandfeel.com
GNU General Public License v3.0
1.13k stars 234 forks source link

How to implement this style, popup like popupmenu #687

Open xcfdszzr opened 2 years ago

xcfdszzr commented 2 years ago
 this is popup

image

I want to make it popupMenu style

image

How am I going to do it
mgarin commented 2 years ago

If you mean that you want the corner to be displayed for your popup just like it is displayed for popupmenu component - I'm afraid that will be hard to implement.

Popup component doesn't keep or track the component it was opened relative to unlike popup menu. To display such corner you would need that information and a custom painter for the component that will make use of it.

So my recommendation in this case - if you absolutely need that corner to be displayed - simply use popup menu with custom content, it is a completely valid use of popup menu (although a bit unconventional).

Alternatively - use WebPopOver component, you can find a showcase for it in demo application:

image

The main difference between using popup menu and popover components would be that popover is basically a separate dialog that captures window focus, while popup menu is just a popup and it doesn't capture focus from your application window.

xcfdszzr commented 2 years ago

Thank you for your reply. I think I need to customize popup for this bug.

mgarin commented 2 years ago

Ultimately - I am considering two options in the future:

Each solution has it's own pros and cons. Making WebPopup have all the functionality might make it convoluted and hard to use in some cases and will make it hard to modify in the future. And making WebPopOver have different display modes would introduce intersection between its functionality and WebPopup functionality.