Transpiled version (8342L) is out of date.
1 | sclass JImageSwitch > JLabel { |
2 | S onImageID, offImageID; |
3 | S offToolTip, onToolTip; |
4 | IVarWithNotify<Bool> var; |
5 | bool on; |
6 | InstantNeverHideToolTip toolTip; |
7 | |
8 | *(S *onImageID, S *offImageID, IVarWithNotify<Bool> *var) { |
9 | toolTip = new InstantNeverHideToolTip(this); |
10 | bindListenerToComponent(this, var, r { set(var!) }); |
11 | on = var!; |
12 | updateIcon(); |
13 | onLeftClick(this, l0 flip); |
14 | } |
15 | |
16 | selfType setToolTips(S onToolTip, S offToolTip) { |
17 | this.onToolTip = onToolTip; |
18 | this.offToolTip = offToolTip; |
19 | updateIcon(); |
20 | this; |
21 | } |
22 | |
23 | void updateIcon { |
24 | toolTip.setText(on ? onToolTip : offToolTip); |
25 | setIcon(imageIcon(loadImage2_cached(on ? onImageID : offImageID))); |
26 | } |
27 | |
28 | void flip { set(!on); } |
29 | |
30 | void set(bool value) swing { |
31 | if (on != value) { |
32 | on = value; |
33 | updateIcon(); |
34 | var.set(on); |
35 | } |
36 | } |
37 | |
38 | bool isOn() { ret on; } |
39 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034552 |
Snippet name: | JImageSwitch - like a checkbox but showing one of two images |
Eternal ID of this version: | #1034552/20 |
Text MD5: | c70699cab3c5e9f0e16aebb407d439e3 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-12 21:52:53 |
Source code size: | 924 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 177 / 353 |
Version history: | 19 change(s) |
Referenced in: | [show references] |