Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1019358 // Test JMenu populated on demand (OK)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (6511L/47K).

!7

p-exp {
  JFrame f = showFrame("Yo");
  JMenu m = addMenu(f, "Dynamic menu");
  addMenuListener(m, new MenuListener {
    @Override
    public void menuSelected(MenuEvent e) {
      // Put your logic here
      JMenu dynamicMenu = (JMenu) e.getSource();
      dynamicMenu.add(new JMenuItem("MenuItem 1.1." + now()));
      dynamicMenu.add(new JMenuItem("MenuItem 1.2." + now()));
    }
    
    @Override
    public void menuDeselected(MenuEvent e) {
      // Remove all MenuItems
      JMenu dynamicMenu = (JMenu) e.getSource();
      dynamicMenu.removeAll();
    }
    
    @Override
    public void menuCanceled(MenuEvent e) {
      // Remove all MenuItems
      JMenu dynamicMenu = (JMenu) e.getSource();
      dynamicMenu.removeAll();
    }
  });
}

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: 414 / 1058
Version history: 2 change(s)
Referenced in: #1019362 - Test JMenu populated on demand (shortened, OK)