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   

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

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: 524 / 1244
Version history: 12 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1001625 & http://1001625.tinybrain.de