Browse Source

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.
spotless
Jannis Weis 3 years ago
parent
commit
dd3b542781
No known key found for this signature in database
GPG Key ID: 7C9D8D4B558049AB
  1. 28
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabber.java
  2. 7
      core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabberUtil.java
  3. 11
      core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java

28
core/src/main/java/com/github/weisj/darklaf/ui/popupmenu/MouseGrabber.java

@ -21,11 +21,8 @@
*/ */
package com.github.weisj.darklaf.ui.popupmenu; package com.github.weisj.darklaf.ui.popupmenu;
import java.applet.Applet;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.List; import java.util.List;
import javax.swing.*; import javax.swing.*;
@ -53,17 +50,14 @@ public class MouseGrabber implements ChangeListener, AWTEventListener, Component
} }
protected void grabWindow(final MenuElement[] newPath) { protected void grabWindow(final MenuElement[] newPath) {
// A grab needs to be added
final Toolkit tk = Toolkit.getDefaultToolkit(); final Toolkit tk = Toolkit.getDefaultToolkit();
AccessController.doPrivileged((PrivilegedAction<Object>) () -> { // A grab needs to be added
tk.addAWTEventListener(MouseGrabber.this, tk.addAWTEventListener(MouseGrabber.this,
AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK |
AWTEvent.MOUSE_WHEEL_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK |
AWTEvent.WINDOW_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK |
GRAB_EVENT_MASK); GRAB_EVENT_MASK);
return null;
});
Component invoker = newPath[0].getComponent(); Component invoker = newPath[0].getComponent();
if (invoker instanceof JPopupMenu) { if (invoker instanceof JPopupMenu) {
@ -86,12 +80,8 @@ public class MouseGrabber implements ChangeListener, AWTEventListener, Component
} }
protected void ungrabWindow() { protected void ungrabWindow() {
final Toolkit tk = Toolkit.getDefaultToolkit();
// The grab should be removed // The grab should be removed
java.security.AccessController.doPrivileged((PrivilegedAction<Object>) () -> { Toolkit.getDefaultToolkit().removeAWTEventListener(MouseGrabber.this);
tk.removeAWTEventListener(MouseGrabber.this);
return null;
});
realUngrabWindow(); realUngrabWindow();
} }
@ -247,7 +237,7 @@ public class MouseGrabber implements ChangeListener, AWTEventListener, Component
protected boolean isInPopup(final Component src) { protected boolean isInPopup(final Component src) {
for (Component c = src; c != null; c = c.getParent()) { for (Component c = src; c != null; c = c.getParent()) {
if (c instanceof Applet || c instanceof Window) { if (c instanceof Window) {
break; break;
} else if (c instanceof JPopupMenu) { } else if (c instanceof JPopupMenu) {
return true; return true;

7
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.AWTEventListener;
import java.awt.event.ComponentListener; import java.awt.event.ComponentListener;
import java.awt.event.WindowListener; import java.awt.event.WindowListener;
import java.security.PrivilegedAction;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
@ -78,11 +77,7 @@ public final class MouseGrabberUtil {
MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager();
menuSelectionManager.removeChangeListener(oldMouseGrabber); menuSelectionManager.removeChangeListener(oldMouseGrabber);
if (oldMouseGrabber instanceof AWTEventListener) { if (oldMouseGrabber instanceof AWTEventListener) {
Toolkit tk = Toolkit.getDefaultToolkit(); Toolkit.getDefaultToolkit().removeAWTEventListener((AWTEventListener) oldMouseGrabber);
java.security.AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
tk.removeAWTEventListener((AWTEventListener) oldMouseGrabber);
return null;
});
} }
MenuElement[] path = menuSelectionManager.getSelectedPath(); MenuElement[] path = menuSelectionManager.getSelectedPath();
if (path.length != 0 && path[0] != null) { if (path.length != 0 && path[0] != null) {

11
core/src/main/java/org/pbjar/jxlayer/repaint/WrappedRepaintManager.java

@ -18,7 +18,6 @@
*/ */
package org.pbjar.jxlayer.repaint; package org.pbjar.jxlayer.repaint;
import java.applet.Applet;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
@ -85,16 +84,6 @@ public abstract class WrappedRepaintManager extends RepaintManager {
delegate.addDirtyRegion(window, x, y, w, h); 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} * Just delegates. {@inheritDoc}
*/ */

Loading…
Cancel
Save