Libraryless. Click here for Pure Java version (8162L/47K).
1 | srecord noeq ScreenSelectorRadioButtons(SimpleLiveValue<Int> lvScreenNr) is Swingable { |
2 | transient ButtonGroup radioButtons; |
3 | transient SingleComponentPanel scp; |
4 | settable bool compactLayout; |
5 | settable bool hideIfOnlyOne; |
6 | settable S screenLabel = "Screen"; |
7 | |
8 | visual swing(-> { |
9 | if (scp == null) { |
10 | scp = singleComponentPanel(); |
11 | awtEveryAndNow(scp, 5.0, r updateScreenCount); |
12 | } |
13 | |
14 | var n = screenCount(); |
15 | radioButtons = jRadioButtons( |
16 | countIteratorAsList(n, |
17 | i -> (compactLayout ? "": screenLabel + " ") + (i+1))); |
18 | setRadioButtonToolTips(radioButtons, i -> "Select screen " + (i+1)); |
19 | selectRadioButton(radioButtons, lvScreenNr!); |
20 | onRadioButtonChange(radioButtons, i -> lvScreenNr.set(i)); |
21 | scp.setComponent(compactLayout |
22 | ? hideIfOnlyOne && n == 1 ? null |
23 | : hstack(flattenList2(nempty(screenLabel) ? jlabel(screenLabel) : null, buttonsInGroup(radioButtons))) |
24 | : jline(flattenList2(buttonsInGroup(radioButtons)))); |
25 | |
26 | ret scp; |
27 | }); |
28 | |
29 | void updateScreenCount() { |
30 | if (radioButtons != null && radioButtons.getButtonCount() != screenCount()) |
31 | visualize(); |
32 | } |
33 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033687 |
Snippet name: | ScreenSelectorRadioButtons |
Eternal ID of this version: | #1033687/20 |
Text MD5: | 8b52a1bc23627b8a2e608dac9d191fda |
Transpilation MD5: | eec17c068ca583e70d8e9a131fbea2cf |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-12-29 16:19:05 |
Source code size: | 1188 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 190 / 354 |
Version history: | 19 change(s) |
Referenced in: | [show references] |