// 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 is ok (WithToolTip 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; }