Libraryless. Click here for Pure Java version (7033L/40K).
1 | sclass ScreenOverlay is AutoCloseable {
|
2 | JWindow window; |
3 | settable Color bgColor |
4 | = colorWithAlpha(Color.blue, 0 /*.5*/); |
5 | //= new Color(0, 255, 0, 128); |
6 | settable Rect bounds; |
7 | settable bool hideOnMouseOver; |
8 | settable Component component; |
9 | |
10 | void show() swing {
|
11 | if (window == null) {
|
12 | if (usingJTattoo()) |
13 | warn("Screen overlays don't really work with JTattoo");
|
14 | |
15 | assertNotNull(+bounds); |
16 | window = new JWindow; |
17 | window.setBackground(bgColor); |
18 | main setBounds(window, bounds); |
19 | window.setAlwaysOnTop(true); |
20 | if (component != null) window.add(component); |
21 | |
22 | disposeWindowOnClick(window); |
23 | |
24 | if (hideOnMouseOver) |
25 | addMouseListener(getContentPane(window), new MouseAdapter {
|
26 | @Override |
27 | public void mouseEntered(MouseEvent e) {
|
28 | hide(); |
29 | } |
30 | }); |
31 | } |
32 | |
33 | window.setVisible(true); |
34 | } |
35 | |
36 | public void hide aka close() swing {
|
37 | if (window == null) ret; |
38 | window.setVisible(false); |
39 | } |
40 | |
41 | void daThing {
|
42 | component(new JPanel {
|
43 | protected void paintComponent(Graphics g) {
|
44 | g.setColor(Color.RED); |
45 | g.drawRect(0, 0, 511, 511); |
46 | } |
47 | }); |
48 | } |
49 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1033972 |
| Snippet name: | ScreenOverlay - always-on-top screen overlay layer that can be translucent |
| Eternal ID of this version: | #1033972/20 |
| Text MD5: | 6b60921749db3a4a146fe6cb545decf5 |
| Transpilation MD5: | 6040725d9b6718c0e74f0c7cef88cfb0 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-01-15 06:20:53 |
| Source code size: | 1257 bytes / 49 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 605 / 814 |
| Version history: | 19 change(s) |
| Referenced in: | [show references] |