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

19
LINES

< > BotCompany Repo | #1001625 // wrap - enclose a Swing component in JScrollPane if it begs for it; also call swing() method and convert arbitrary objects to jlabel

JavaX fragment (include)

// c = Component or something implementing swing()
static JComponent wrap(O swingable) {
  ret _recordNewSwingComponent(wrap_2(swingable));
}

static JComponent wrap_2(O swingable) {
  if (swingable == null) null;
  JComponent c;
  if (swingable cast Component) c = componentToJComponent(swingable);
  ifclass Swingable
    else if (swingable instanceof Swingable) c = componentToJComponent(swingable/Swingable.visualize());
  endif
  else c = componentToJComponent((Component) callOpt(swingable, "swing"));
  if (c instanceof JTable || c instanceof JList
    || c instanceof JTextArea || c instanceof JEditorPane
    || c instanceof JTextPane || c instanceof JTree)
    ret jscroll(c);
  ret c == null ? jlabel(str(swingable)) : c;
}

Author comment

Wrap a Swing component for display (add JScrollPane)

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001625
Snippet name: wrap - enclose a Swing component in JScrollPane if it begs for it; also call swing() method and convert arbitrary objects to jlabel
Eternal ID of this version: #1001625/13
Text MD5: 9822f4a472127372557f1753a92d0bb4
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-05 23:11:19
Source code size: 752 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 775 / 1594
Version history: 12 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000382 - Answer for ferdie (>> t = 1, f = 0)