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

38
LINES

< > BotCompany Repo | #1020061 // dm_addReloadButtonToModuleTitlePane

JavaX fragment (include)

sclass dm_ReloadButton extends JLabel {
  O moduleID;
  
  *(fO *moduleID) {
    initImageLabel(this, #1101440);
    setToolTip(this, "Module can be reloaded");
    onClick(this, r {
      removeFromParent(dm_ReloadButton.this);
      dm_reloadModuleInBackground(moduleID);
    });
  }
}

// tested with JTattoo and Windows L&F
sbool dm_addReloadButtonToModuleTitlePane(fO moduleID) {
  ret swing(func -> bool {
    final JComponent c = internalFrameTitleComponent((JInternalFrame) dm_frame(moduleID));
    if (c == null) false;
    if (containsChildWithShortName(c, 'dm_ReloadButton)) false;
    
    final dm_ReloadButton btn = swingNu(dm_ReloadButton, moduleID);
    addBottomMargin(btn, 2);
    final int nChildren = countChildren(c);
    final int w = preferredWidth(btn), h = preferredHeight(btn), gap = 5;
    addComponent(c, btn);
    final Runnable relayout = r {
      setBounds(btn,
        max(30, minXOfFirstNChildren_rightOf(c, nChildren, 20)-w-gap),
        (c.getHeight()-h)/2, w, h)
    };
    final ComponentListener resizeListener = resizeListener(relayout);
    bindToComponent(btn,
      r { c.addComponentListener(resizeListener); callF(relayout) },
      r { c.removeComponentListener(resizeListener) });
    vmBus_send('addedReloadButtonToModule, moduleID);
    true;
  });
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020061
Snippet name: dm_addReloadButtonToModuleTitlePane
Eternal ID of this version: #1020061/17
Text MD5: b972494e18e25fc1f2702ab32c78986d
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-07 01:35:54
Source code size: 1336 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 318 / 383
Version history: 16 change(s)
Referenced in: [show references]