回答編集履歴
2
見直しキャンペーン中
answer
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Windows限定です。すべて貫通するので移動ができません。
|
2
2
|
ざっと試した限りは動いてそうですが、何か問題があるかもしれません。
|
3
3
|
|
4
|
-
`jna-5.6.0.jar`・`jna-platform-5.6.0.jar`を、エディタにドロップするなりして
|
4
|
+
`jna-5.6.0.jar`・`jna-platform-5.6.0.jar`を、エディタにドロップするなりして使えるようにしておきます。
|
5
5
|
[java-native-access/jna: Java Native Access](https://github.com/java-native-access/jna)
|
6
6
|
```Processing
|
7
7
|
import processing.awt.PSurfaceAWT;
|
1
見直しキャンペーン中
answer
CHANGED
@@ -1,67 +1,63 @@
|
|
1
|
-
Windows限定です。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
`
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
import
|
14
|
-
import
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
frame.
|
32
|
-
frame.
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
参考
|
65
|
-
[swing - Java: Making a window click-through (including text/images) - Stack Overflow](https://stackoverflow.com/questions/11217660/java-making-a-window-click-through-including-text-images)
|
66
|
-
|
1
|
+
Windows限定です。すべて貫通するので移動ができません。
|
2
|
+
ざっと試した限りは動いてそうですが、何か問題があるかもしれません。
|
3
|
+
|
4
|
+
`jna-5.6.0.jar`・`jna-platform-5.6.0.jar`を、エディタにドロップするなりして、使えるようにしておきます。
|
5
|
+
[java-native-access/jna: Java Native Access](https://github.com/java-native-access/jna)
|
6
|
+
```Processing
|
7
|
+
import processing.awt.PSurfaceAWT;
|
8
|
+
|
9
|
+
import java.awt.Component;
|
10
|
+
import java.awt.Frame;
|
11
|
+
|
12
|
+
import com.sun.jna.Native;
|
13
|
+
import com.sun.jna.platform.win32.User32;
|
14
|
+
import com.sun.jna.platform.win32.WinDef;
|
15
|
+
import com.sun.jna.platform.win32.WinUser;
|
16
|
+
|
17
|
+
void setup() {
|
18
|
+
size(300, 150);
|
19
|
+
frameRate(1);
|
20
|
+
stroke(255);
|
21
|
+
textSize(72);
|
22
|
+
|
23
|
+
PSurfaceAWT awtSurface = (PSurfaceAWT)surface;
|
24
|
+
PSurfaceAWT.SmoothCanvas smoothCanvas = (PSurfaceAWT.SmoothCanvas)awtSurface.getNative();
|
25
|
+
Frame frame = smoothCanvas.getFrame();
|
26
|
+
|
27
|
+
frame.removeNotify();
|
28
|
+
frame.setSize(width, height);
|
29
|
+
frame.setAlwaysOnTop(true);
|
30
|
+
frame.setUndecorated(true);
|
31
|
+
frame.setOpacity(0.5f);
|
32
|
+
frame.addNotify();
|
33
|
+
|
34
|
+
setTransparent(frame);
|
35
|
+
}
|
36
|
+
|
37
|
+
void draw() {
|
38
|
+
background(0);
|
39
|
+
if (second() % 2 == 0)
|
40
|
+
text(nf(hour(), 2) + ":" + nf(minute(), 2), 50, 100);
|
41
|
+
else
|
42
|
+
text(nf(hour(), 2) + " " + nf(minute(), 2), 50, 100);
|
43
|
+
}
|
44
|
+
|
45
|
+
// [swing - Java: Making a window click-through (including text/images) - Stack Overflow](https://stackoverflow.com/questions/11217660/java-making-a-window-click-through-including-text-images)
|
46
|
+
private static void setTransparent(Component w) {
|
47
|
+
WinDef.HWND hwnd = getHWnd(w);
|
48
|
+
int wl = User32.INSTANCE.GetWindowLong(hwnd, WinUser.GWL_EXSTYLE);
|
49
|
+
wl = wl | WinUser.WS_EX_LAYERED | WinUser.WS_EX_TRANSPARENT;
|
50
|
+
User32.INSTANCE.SetWindowLong(hwnd, WinUser.GWL_EXSTYLE, wl);
|
51
|
+
}
|
52
|
+
|
53
|
+
private static WinDef.HWND getHWnd(Component w) {
|
54
|
+
WinDef.HWND hwnd = new WinDef.HWND();
|
55
|
+
hwnd.setPointer(Native.getComponentPointer(w));
|
56
|
+
return hwnd;
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
参考
|
61
|
+
[swing - Java: Making a window click-through (including text/images) - Stack Overflow](https://stackoverflow.com/questions/11217660/java-making-a-window-click-through-including-text-images)
|
62
|
+
|
67
63
|

|