Libraryless. Click here for Pure Java version (64L/1K).
static class PopupMenuHelper extends MouseAdapter { JPopupMenu menu; Point point; /** override me */ swappable void fillMenu() { } public void mousePressed(MouseEvent e) { displayMenu(e); } public void mouseReleased(MouseEvent e) { displayMenu(e); } private void displayMenu(MouseEvent e) { boolean popupTrigger = e.isPopupTrigger(); if (popupTrigger) { JPopupMenu menu = new JPopupMenu(); int count = menu.getComponentCount(); this.menu = menu; this.point = e.getPoint(); fillMenu(); this.menu = null; if (menu.getComponentCount() != count) menu.show(e.getComponent(), e.getX(), e.getY()); } } public void install(JComponent component) { component.addMouseListener(this); } }
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000839 |
Snippet name: | PopupMenuHelper |
Eternal ID of this version: | #1000839/2 |
Text MD5: | 57785762592ba949f9f1c922abc65e0e |
Transpilation MD5: | 6a4e2489a9fee90cc0ee7bee430a383e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-25 20:20:44 |
Source code size: | 817 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 727 / 2937 |
Version history: | 1 change(s) |
Referenced in: | [show references] |