Libraryless. Click here for Pure Java version (7033L/40K).
sclass ScreenOverlay is AutoCloseable { JWindow window; settable Color bgColor = colorWithAlpha(Color.blue, 0 /*.5*/); //= new Color(0, 255, 0, 128); settable Rect bounds; settable bool hideOnMouseOver; settable Component component; void show() swing { if (window == null) { if (usingJTattoo()) warn("Screen overlays don't really work with JTattoo"); assertNotNull(+bounds); window = new JWindow; window.setBackground(bgColor); main setBounds(window, bounds); window.setAlwaysOnTop(true); if (component != null) window.add(component); disposeWindowOnClick(window); if (hideOnMouseOver) addMouseListener(getContentPane(window), new MouseAdapter { @Override public void mouseEntered(MouseEvent e) { hide(); } }); } window.setVisible(true); } public void hide aka close() swing { if (window == null) ret; window.setVisible(false); } void daThing { component(new JPanel { protected void paintComponent(Graphics g) { g.setColor(Color.RED); g.drawRect(0, 0, 511, 511); } }); } }
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: | 269 / 445 |
Version history: | 19 change(s) |
Referenced in: | [show references] |