Libraryless. Click here for Pure Java version (3758L/25K).
// menuParams: text, Runnable, ... // also: position := 'left/'center/'right static JButton jPopDownButton(S text, fO... menuParams) { ret jbutton((empty(text) ? "" : text + " ") + unicode_downPointingTriangle(), r { new JPopupMenu menu; int emptyCount = menu.getComponentCount(); S position = cast optPar_ignoreOddLength position(menuParams); // TODO: this fails when you include a separator without a following null fillJPopupMenu(menu, paramsWithout(menuParams, 'position)); if (menu.getComponentCount() != emptyCount) { JButton btn = heldInstance(JButton); int x = 0; if (eq(position, 'center)) x = (btn.getWidth()-getPreferredWidth(menu))/2; else if (eq(position, 'right)) x = btn.getWidth()-getPreferredWidth(menu); menu.show(btn, x, btn.getHeight()); } }); }
download show line numbers debug dex old transpilations
Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1020102 |
Snippet name: | jPopDownButton - button that shows a popup menu. Automatically adds a small triangle to the button text |
Eternal ID of this version: | #1020102/7 |
Text MD5: | 48a5678814441fbd143991194b0e42d6 |
Transpilation MD5: | 8a383792fe2dfda76387b50444e47660 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-11 19:00:50 |
Source code size: | 839 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 381 / 474 |
Version history: | 6 change(s) |
Referenced in: | [show references] |