Transpiled version (6836L) is out of date.
// x = names and components interleaving. // or just components. // or just names. // also, first element can be index of tab to open at start // also, SUPER short demo syntax: jtabs(3) // also, you can pass a Collection containing the elements static JTabbedPane fillJTabs(final JTabbedPane tabs, fO... _x) { if (tabs == null) null; clearTabs(tabs); O[] x = flattenArray2(_x); ifdef fillJTabs_debug print("fillJTabs length=" + l(_x) + " => " + l(x)); endifdef int idx = 0; if (get(x, 0) instanceof Int) { idx = asInt(get(x, 0)); x = dropFirst(x); if (empty(x)) { x = arrayrep(null, idx); idx = 0; } } int n = 0; for (int i = 0; i < l(x); i++) { ++n; // is it a component? O o = x[i]; if (isComponentOrSwingable(o)) addTab(tabs, "Tab " + n, wrap(o)); else { // assume it's a tab name, optionally followed by a component S toolTip = ""; // WithToolTip<S> is ok (WithToolTip<Component> not yet supported) if (o cast WithToolTip) { toolTip = o.toolTip(); o = o!; } S name = str(or(o, "Tab " + n)); ifdef fillJTabs_debug print("tab " + i + ": " + name); endifdef Component c; if (isComponentOrSwingable(get(x, i+1))) c = wrap(get(x, ++i)); else c = new JPanel; addTabWithToolTip(tabs, name, toolTip, wrap(c)); } } if (idx != 0) tabs.setSelectedIndex(min(tabs.getTabCount()-1, idx)); ret tabs; }
download show line numbers debug dex old transpilations
Travelled to 10 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, qsqiayxyrbia, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1020846 |
| Snippet name: | fillJTabs - fill JTabbedPane |
| Eternal ID of this version: | #1020846/14 |
| Text MD5: | 8b000d634455409870fa1999a7722f12 |
| Author: | stefan |
| Category: | |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-01-31 22:52:47 |
| Source code size: | 1556 bytes / 55 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 599 / 788 |
| Version history: | 13 change(s) |
| Referenced in: | [show references] |