Libraryless. Click here for Pure Java version (10394L/59K).
sclass JPopDownButton > JButton { S menuPosition = "left"; // or "center" or "right" *() { this(""); } *(S text) { super(joinNemptiesWithSpace(text, unicode_downPointingTriangle())); main addActionListener(this, r openMenu); } *(IVF1<JPopupMenu> *fillMenu) { this(); } selfType content(O... items) { onFillingMenu(menu -> fillJPopupMenu(menu, items)); this; } event fillingMenu(JPopupMenu menu); swappable void fillMenu(JPopupMenu menu) { fillingMenu(menu); } void openMenu { new JPopupMenu menu; int emptyCount = menu.getComponentCount(); fillMenu(menu); if (menu.getComponentCount() == emptyCount) ret; int x = 0; if (eq(menuPosition, "center")) x = (getWidth()-getPreferredWidth(menu))/2; else if (eq(menuPosition, "right")) x = getWidth()-getPreferredWidth(menu); menu.show(this, x, getHeight()); } visual this; }
Began life as a copy of #1020102
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034224 |
Snippet name: | JPopDownButton - generalized jPopDownButton |
Eternal ID of this version: | #1034224/8 |
Text MD5: | 8c865c9c059b240681bf792ce6b76162 |
Transpilation MD5: | d5975120704fc219aee17db24ddf11ed |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-06-16 16:48:24 |
Source code size: | 956 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 153 / 298 |
Version history: | 7 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |