1 | sclass ImageMachine { |
2 | JTextField tf; |
3 | SingleComponentPanel scp; |
4 | ImageSurface is; |
5 | Q q; |
6 | volatile bool boss; // boss mode (after pressing Escape) |
7 | |
8 | void start() { |
9 | final S word = randomEnglishWord(); |
10 | swing { |
11 | q = new Q(true); |
12 | showMaximizedFrame("Automatic Image Machine!", northAndCenter(tf = setTextFieldFontSize(jCenteredTextField(word), 20), scp = new SingleComponentPanel)); |
13 | // Escape = Boss Key! |
14 | registerEscape(getFrame(tf), r { |
15 | boss = true; |
16 | tf.setText(""); scp.noComponent(); |
17 | }); |
18 | |
19 | onEnterAndNow(tf, r { |
20 | boss = false; |
21 | awt { tf.selectAll(); } |
22 | final S text = getTextTrim(tf); |
23 | q.add(r { |
24 | if (boss) ret; |
25 | long time = sysNow(); |
26 | loading { |
27 | final BufferedImage img = quickVisualize(text); |
28 | if (boss) ret; |
29 | awt { newImage(text, img); } |
30 | } |
31 | sleepUntilSys(time+1000); // min display time |
32 | }); |
33 | }); |
34 | hideConsole(); |
35 | } |
36 | } |
37 | |
38 | void newImage(S text, BufferedImage img) { |
39 | JLabel lbl = jcenteredlabel(text); |
40 | lbl.setFont(sansSerifBold(20)); |
41 | scp.setComponent(centerAndSouth( |
42 | jscroll_centered(is = new ImageSurface(img)), |
43 | lbl); |
44 | awt { is.zoomToWindow(); } |
45 | } |
46 | } |
Began life as a copy of #1007146
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: | #1007154 |
Snippet name: | class ImageMachine |
Eternal ID of this version: | #1007154/3 |
Text MD5: | 613af1a6fd66a2d4def810c7a80714fb |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-08 01:03:55 |
Source code size: | 1323 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 414 / 611 |
Version history: | 2 change(s) |
Referenced in: | [show references] |