Download Jar. Uses 3874K of libraries. Click here for Pure Java version (3997L/27K).
1 | !7 |
2 | |
3 | static JFrame frame; |
4 | static S imageMD5, text; |
5 | |
6 | p-substance { |
7 | frame = showFrame("Clipboard"); |
8 | installTimer(frame, 3000, 0, r { |
9 | update(); |
10 | }); |
11 | hideConsoleIfMainProgram(); |
12 | } |
13 | |
14 | svoid update { |
15 | BufferedImage img = getImageFromClipboard(); |
16 | if (img != null) { |
17 | S md5 = md5OfRGBImage(new RGBImage(img)); |
18 | if (neq(md5, imageMD5)) { |
19 | imageMD5 = md5; |
20 | text = null; |
21 | setFrameContents(frame, jscroll(new ImageSurface(img))); |
22 | setFrameTitle(frame, "Clipboard: " + img.getWidth() + "*" + img.getHeight() + " px image"); |
23 | } |
24 | ret; |
25 | } |
26 | imageMD5 = null; |
27 | S s = getTextFromClipboard(); |
28 | if (s != null) { |
29 | if (neq(text, s)) { |
30 | text = s; |
31 | setFrameContents(frame, typeWriterTextArea(s)); |
32 | setFrameTitle(frame, "Clipboard: " + quote(escapeNewLines(shorten(s, 256)))); |
33 | } |
34 | ret; |
35 | } |
36 | text = null; |
37 | // empty clipboard or unknown contents |
38 | setFrameContents(frame, new JPanel); |
39 | |
40 | Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); |
41 | setFrameTitle(frame, transferable != null ? "Unknown clipboard contents (" + join(", ", mimeTypes(transferable)) + ")" : "Empty clipboard"); |
42 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006099 |
Snippet name: | Show clipboard (live-updated) |
Eternal ID of this version: | #1006099/6 |
Text MD5: | f0de8f5b01387d04a289338beddc98bf |
Transpilation MD5: | d8d1e61efbd1e292c13c649972b74c40 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-23 14:51:35 |
Source code size: | 1215 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 665 / 1342 |
Version history: | 5 change(s) |
Referenced in: | [show references] |