Libraryless. Click here for Pure Java version (14450L/100K).
1 | !7 |
2 | |
3 | sclass ImagePreview extends DynSCP { |
4 | new DynModuleRef mate; |
5 | |
6 | transient Image shownImage; |
7 | |
8 | JComponent visualize2() { |
9 | Image image = shownImage; |
10 | if (image == null) ret jcenteredlabel("Need image"); |
11 | ret jimage(image); |
12 | } |
13 | |
14 | Image imageFromMate() { |
15 | ret castCall(mate!, 'getImage); |
16 | } |
17 | |
18 | void update { |
19 | lock lock; |
20 | |
21 | // notice mate gone away |
22 | if (mate! != null && !dm_moduleStillThere(mate!)) { |
23 | mate.set(null); |
24 | setField(shownImage := null); |
25 | revisualize2(); |
26 | } |
27 | |
28 | // find new mate |
29 | if (mate! == null) |
30 | if (setField(mate := DynModuleRef(dm_findMateOfType(this, 'ImageInfo)))) |
31 | revisualize2(); |
32 | |
33 | if (setField(shownImage := imageFromMate())) |
34 | revisualize2(); |
35 | } |
36 | } |
Began life as a copy of #1015922
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016035 |
Snippet name: | Image Preview |
Eternal ID of this version: | #1016035/11 |
Text MD5: | 2caff3719884db188d8a9db5f96217b8 |
Transpilation MD5: | be0cebb583351ea4268e94dc93e73e24 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-08 18:38:08 |
Source code size: | 793 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 421 / 565 |
Version history: | 10 change(s) |
Referenced in: | [show references] |