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

28
LINES

< > BotCompany Repo | #1020262 // showYesToAcceptPopup

JavaX fragment (include)

//static double showYesToAcceptPopup_hideAfter = 10.0;
sS showYesToAcceptPopup_imageID = #1101458; // #1101459 for "ok" instead of "yes" (wit.ai is bad at recognizing "yes")

static YesPopup showYesToAcceptPopup(final Component c, fO... _) {
  ret c == null ? null : swing(func -> YesPopup {
    final JDesktopPane desktop = parentOfType(c, JDesktopPane.class);
    if (desktop == null) null;
    S imageID = optPar(_, imageID := showYesToAcceptPopup_imageID);
    int height = optPar(_, height := 114);
    final YesPopup popup = setSizeToPreferredSize(YesPopup(c, imageID, height));
    fO mover = optPar(_, 'mover); // voidfunc(Component c, Component popup)
    Runnable moveIt = r {
      if (!isComponentShowing(c)) ret with removeFromParent(popup);
      if (mover != null)
        callF(mover, c, popup);
      else {
        Rect r = boundsInParent(c, desktop);
        setLocation(popup, r.x+r.w/2, r.y-popup.getHeight()-5);
      }
    };
    desktop.add(popup, JLayeredPane.POPUP_LAYER);
    onClick(popup, r { removeFromParent(popup) });
    callF(moveIt);
    awtEvery(popup, 100, moveIt);
   //removeFromParentAfter(showYesToAcceptPopup_hideAfter, popup);
    ret popup;
  });
}

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: #1020262
Snippet name: showYesToAcceptPopup
Eternal ID of this version: #1020262/27
Text MD5: 5ba432212f7757876968c21bb15c7b39
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-22 17:03:47
Source code size: 1219 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 246 / 335
Version history: 26 change(s)
Referenced in: [show references]