Libraryless. Click here for Pure Java version (3335L/22K).
1 | static new ThreadLocal<Bool> addMenu_addIfEmpty; // defaults to true |
2 | |
3 | static JMenu addMenu(final Component c, fS menuName, fO... items) { |
4 | final RootPaneContainer frame = getPossiblyInternalFrame(c); |
5 | ret (JMenu) swing(func { |
6 | JMenuBar bar = addMenuBar((Component) frame); |
7 | Pair<S, Int> p = jmenu_autoMnemonic(menuName); |
8 | JMenu menu = getMenuNamed(bar, p.a); |
9 | bool isNew = menu == null; |
10 | ifdef addMenu_debug |
11 | print("addMenu " + menuName + " " + isNew); |
12 | endifdef |
13 | if (isNew) |
14 | menu = new JMenu(p.a); |
15 | else |
16 | menu.removeAll(); |
17 | menu.setMnemonic(p.b); |
18 | fillJMenu(menu, items); |
19 | if (isNew) { |
20 | if (!isFalse(addMenu_addIfEmpty!) || menuItemCount(menu) > 0) { |
21 | bar.add(menu); |
22 | revalidate((Component) frame); |
23 | } |
24 | } |
25 | ret menu; |
26 | }); |
27 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004034 |
Snippet name: | addMenu - replaces whole menu if it is there |
Eternal ID of this version: | #1004034/14 |
Text MD5: | 4e80e993d32ffbc4cdc8d780b53384f5 |
Transpilation MD5: | 03873f97a679ad7f161da0e010cc3336 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-08-30 14:19:02 |
Source code size: | 830 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 733 / 780 |
Version history: | 13 change(s) |
Referenced in: | [show references] |