Libraryless. Click here for Pure Java version (7122L/40K).
1 | // x = names and components interleaving. |
2 | // or just components. |
3 | // or just names. |
4 | // also, you can pass a Collection containing the elements |
5 | svoid addTabs(JTabbedPane tabs, O... x) { |
6 | if (tabs == null) ret; |
7 | x = flattenToArray(x); |
8 | for i over x: { |
9 | // is it a component? |
10 | O o = x[i]; |
11 | if (isComponentOrSwingable(o)) |
12 | addTab(tabs, "Tab " + (tabCount(tabs)+1), wrap(o)); |
13 | else { |
14 | // assume it's a tab name, optionally followed by a component |
15 | S toolTip = ""; |
16 | |
17 | // WithToolTip<S> is ok (WithToolTip<Component> not yet supported) |
18 | if (o cast WithToolTip) { |
19 | toolTip = o.toolTip(); |
20 | o = o!; |
21 | } |
22 | S name = str(or(o, "Tab " + tabCount(tabs)+1)); |
23 | Component c; |
24 | if (isComponentOrSwingable(get(x, i+1))) |
25 | c = wrap(get(x, ++i)); |
26 | else |
27 | c = new JPanel; |
28 | addTabWithToolTip(tabs, name, toolTip, wrap(c)); |
29 | } |
30 | } |
31 | } |
Began life as a copy of #1020846
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034285 |
Snippet name: | addTabs - fill JTabbedPane |
Eternal ID of this version: | #1034285/8 |
Text MD5: | 34e1e843b57d2477ecad0490c8940f22 |
Transpilation MD5: | 1295d520876eb70269bf40a826a8691c |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-31 22:54:30 |
Source code size: | 937 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 134 / 205 |
Version history: | 7 change(s) |
Referenced in: | [show references] |