1 | // TODO: hide on mouse over |
2 | |
3 | static BlinkScreenArea blinkScreenArea(Rectangle r) { |
4 | ret new BlinkScreenArea(r).go(); |
5 | } |
6 | |
7 | sclass BlinkScreenArea { |
8 | int count, max = 12; |
9 | int delay = 150; |
10 | BufferedImage img, img2; |
11 | JWindow window; |
12 | JLabel lbl; |
13 | Rectangle area; |
14 | |
15 | *(Rectangle r) ctex { |
16 | // clip to screen |
17 | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize (); |
18 | r = new Rectangle(screenSize).intersection(r); |
19 | area = r; |
20 | |
21 | new Robot robot; |
22 | img = robot.createScreenCapture(r); |
23 | img2 = changeBrightness(img, 2f); |
24 | img = changeBrightness(img, 0.5f); |
25 | } |
26 | |
27 | BlinkScreenArea go() { |
28 | awt { |
29 | // make JWindow |
30 | window = new JWindow; |
31 | window.setBounds(area); |
32 | lbl = new JLabel(new ImageIcon(img2)); |
33 | window.add(lbl); |
34 | window.setAlwaysOnTop(true); |
35 | window.setVisible(true); |
36 | |
37 | installTimer(lbl, delay, r { step(); }); |
38 | } |
39 | ret this; |
40 | } |
41 | |
42 | void step() { |
43 | ++count; |
44 | if (count > max) |
45 | print("huh?"); |
46 | else if (count == max) |
47 | window.dispose(); // should stop timer too |
48 | else |
49 | lbl.setIcon(new ImageIcon((count & 1) == 0 ? img : img2)); |
50 | } |
51 | } |
Began life as a copy of #1003734
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003735 |
Snippet name: | blinkScreenArea |
Eternal ID of this version: | #1003735/1 |
Text MD5: | 4a9f54901b633787b9b405c3aa8a668a |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-26 16:59:27 |
Source code size: | 1202 bytes / 51 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 536 / 540 |
Referenced in: | [show references] |