Download Jar. Libraryless. Click here for Pure Java version (6511L/47K).
1 | !7 |
2 | |
3 | p-exp { |
4 | JFrame f = showFrame("Yo"); |
5 | JMenu m = addMenu(f, "Dynamic menu"); |
6 | addMenuListener(m, new MenuListener { |
7 | @Override |
8 | public void menuSelected(MenuEvent e) { |
9 | // Put your logic here |
10 | JMenu dynamicMenu = (JMenu) e.getSource(); |
11 | dynamicMenu.add(new JMenuItem("MenuItem 1.1." + now())); |
12 | dynamicMenu.add(new JMenuItem("MenuItem 1.2." + now())); |
13 | } |
14 | |
15 | @Override |
16 | public void menuDeselected(MenuEvent e) { |
17 | // Remove all MenuItems |
18 | JMenu dynamicMenu = (JMenu) e.getSource(); |
19 | dynamicMenu.removeAll(); |
20 | } |
21 | |
22 | @Override |
23 | public void menuCanceled(MenuEvent e) { |
24 | // Remove all MenuItems |
25 | JMenu dynamicMenu = (JMenu) e.getSource(); |
26 | dynamicMenu.removeAll(); |
27 | } |
28 | }); |
29 | } |
download show line numbers debug dex old transpilations
Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019358 |
Snippet name: | Test JMenu populated on demand (OK) |
Eternal ID of this version: | #1019358/3 |
Text MD5: | 866b7065b5493ce908a9dbd1521e2cef |
Transpilation MD5: | 5e83847643e92a7e2767eec202a35883 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-04 15:31:05 |
Source code size: | 785 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 483 / 1223 |
Version history: | 2 change(s) |
Referenced in: | [show references] |