From efbd96cd92b3f5073311603e6343b9bee4798c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Tue, 29 Sep 2026 12:03:04 +0200 Subject: [PATCH] use proper swing components --- .../beatrice/autosqueal/ui/MainWindow.java | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/main/java/wtf/beatrice/autosqueal/ui/MainWindow.java b/src/main/java/wtf/beatrice/autosqueal/ui/MainWindow.java index 7c4ec18..08d1c9f 100644 --- a/src/main/java/wtf/beatrice/autosqueal/ui/MainWindow.java +++ b/src/main/java/wtf/beatrice/autosqueal/ui/MainWindow.java @@ -31,7 +31,7 @@ public class MainWindow private static final long AWAY_POLL_INTERVAL_SECONDS = 1L; private final JFrame frame = new JFrame(); - private Button toggleButton; + private JButton toggleButton; private ScheduledExecutorService periodicScheduler; private ExecutorService movementExecutor; @@ -56,7 +56,7 @@ public class MainWindow } }); - toggleButton = new Button(); + toggleButton = new JButton(); toggleButton.setBounds(new Rectangle((WINDOW_WIDTH / 2) - 60, WINDOW_HEIGHT - 60, 120, 30)); toggleButton.addActionListener(e -> toggleRunning()); frame.add(toggleButton); @@ -108,24 +108,6 @@ public class MainWindow return null; } - public BufferedImage getBufferedImage(Image img) { - if (img instanceof BufferedImage image) - { - return image; - } - - // Create a buffered image with transparency - BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB); - - // Draw the image on to the buffered image - Graphics2D bGr = bimage.createGraphics(); - bGr.drawImage(img, 0, 0, null); - bGr.dispose(); - - // Return the buffered image - return bimage; - } - /** * Toggles the automation on or off. Safe to call from any thread: the actual * work is always marshalled to the EDT, since it touches Swing components. @@ -197,7 +179,7 @@ public class MainWindow String hotkey = "[" + NativeKeyEvent.getKeyText(NativeKeyEvent.VC_CONTROL) + "]" + "[" + NativeKeyEvent.getKeyText(NativeKeyEvent.VC_ALT) + "]"; - toggleButton.setLabel((cursorMover == null ? "Start " : "Stop ") + hotkey); + toggleButton.setText((cursorMover == null ? "Start " : "Stop ") + hotkey); } } \ No newline at end of file