From dd3b542781f02821ae03aa8563bce503b0051018 Mon Sep 17 00:00:00 2001 From: Jannis Weis <31143295+weisJ@users.noreply.github.com> Date: Tue, 28 Dec 2021 12:41:54 +0100 Subject: [PATCH] Remove usage of java.applet.Applet and java.security.* Both are scheduled for removal and only occur because the respective code replicates JDK classes. All occurrences aren't strictly necessary hence can be removed. --- .../darklaf/ui/popupmenu/MouseGrabber.java | 28 ++++++------------- .../ui/popupmenu/MouseGrabberUtil.java | 7 +---- .../repaint/WrappedRepaintManager.java | 11 -------- 3 files changed, 10 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabber.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabber.java index 0e10a22a..1fae9c8a 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabber.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabber.java @@ -21,11 +21,8 @@ */ package com.github.weisj.darklaf.ui.popupmenu; -import java.applet.Applet; import java.awt.*; import java.awt.event.*; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.List; import javax.swing.*; @@ -53,17 +50,14 @@ public class MouseGrabber implements ChangeListener, AWTEventListener, Component } protected void grabWindow(final MenuElement[] newPath) { - // A grab needs to be added final Toolkit tk = Toolkit.getDefaultToolkit(); - AccessController.doPrivileged((PrivilegedAction) () -> { - tk.addAWTEventListener(MouseGrabber.this, - AWTEvent.MOUSE_EVENT_MASK | - AWTEvent.MOUSE_MOTION_EVENT_MASK | - AWTEvent.MOUSE_WHEEL_EVENT_MASK | - AWTEvent.WINDOW_EVENT_MASK | - GRAB_EVENT_MASK); - return null; - }); + // A grab needs to be added + tk.addAWTEventListener(MouseGrabber.this, + AWTEvent.MOUSE_EVENT_MASK | + AWTEvent.MOUSE_MOTION_EVENT_MASK | + AWTEvent.MOUSE_WHEEL_EVENT_MASK | + AWTEvent.WINDOW_EVENT_MASK | + GRAB_EVENT_MASK); Component invoker = newPath[0].getComponent(); if (invoker instanceof JPopupMenu) { @@ -86,12 +80,8 @@ public class MouseGrabber implements ChangeListener, AWTEventListener, Component } protected void ungrabWindow() { - final Toolkit tk = Toolkit.getDefaultToolkit(); // The grab should be removed - java.security.AccessController.doPrivileged((PrivilegedAction) () -> { - tk.removeAWTEventListener(MouseGrabber.this); - return null; - }); + Toolkit.getDefaultToolkit().removeAWTEventListener(MouseGrabber.this); realUngrabWindow(); } @@ -247,7 +237,7 @@ public class MouseGrabber implements ChangeListener, AWTEventListener, Component protected boolean isInPopup(final Component src) { for (Component c = src; c != null; c = c.getParent()) { - if (c instanceof Applet || c instanceof Window) { + if (c instanceof Window) { break; } else if (c instanceof JPopupMenu) { return true; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java index 0c929027..fe6c4432 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java @@ -25,7 +25,6 @@ import java.awt.*; import java.awt.event.AWTEventListener; import java.awt.event.ComponentListener; import java.awt.event.WindowListener; -import java.security.PrivilegedAction; import javax.swing.*; import javax.swing.event.ChangeListener; @@ -78,11 +77,7 @@ public final class MouseGrabberUtil { MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); menuSelectionManager.removeChangeListener(oldMouseGrabber); if (oldMouseGrabber instanceof AWTEventListener) { - Toolkit tk = Toolkit.getDefaultToolkit(); - java.security.AccessController.doPrivileged((PrivilegedAction) () -> { - tk.removeAWTEventListener((AWTEventListener) oldMouseGrabber); - return null; - }); + Toolkit.getDefaultToolkit().removeAWTEventListener((AWTEventListener) oldMouseGrabber); } MenuElement[] path = menuSelectionManager.getSelectedPath(); if (path.length != 0 && path[0] != null) { diff --git a/core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java b/core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java index 02218436..c60ba7e1 100644 --- a/core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java +++ b/core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java @@ -18,7 +18,6 @@ */ package org.pbjar.jxlayer.repaint; -import java.applet.Applet; import java.awt.*; import javax.swing.*; @@ -85,16 +84,6 @@ public abstract class WrappedRepaintManager extends RepaintManager { delegate.addDirtyRegion(window, x, y, w, h); } - /** - * Just delegates. {@inheritDoc} - */ - @Override - @Deprecated - @SuppressWarnings("deprecation") - public void addDirtyRegion(final Applet applet, final int x, final int y, final int w, final int h) { - delegate.addDirtyRegion(applet, x, y, w, h); - } - /** * Just delegates. {@inheritDoc} */