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

21
LINES

< > BotCompany Repo | #1017722 // tempAdd - temporarily add to collection or container

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (7901L/45K).

static <A> AutoCloseable tempAdd(Cl<A> l, A a) {
  if (l == null || l.contains(a)) null;
  l.add(a);
  ret new tempAdd_undo(l, a);
}

srecord noeq tempAdd_undo<A>(Cl<A> l, A a) is AutoCloseable {
  close { l.remove(a); }
}

static AutoCloseable tempAdd(Container a, Component b) {
  if (a == null || b == null) null;
  swing {
    if (b.getParent() == a) null;
    a.add(b);
    ret -> swing {
      if (b.getParent() == a)
        removeFromParent(b);
    };
  }
}

Author comment

Began life as a copy of #1016563

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017722
Snippet name: tempAdd - temporarily add to collection or container
Eternal ID of this version: #1017722/7
Text MD5: 09b1292b6db7e9d7d58f4fc28a76f803
Transpilation MD5: 5c673b82210a3d6c70ca5ebdd02a3fd2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-06 01:22:35
Source code size: 485 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 392 / 492
Version history: 6 change(s)
Referenced in: [show references]