From 88cbd8a3a3ab5573d70c5c77551b054cf331c166 Mon Sep 17 00:00:00 2001 From: weisj <31143295+weisJ@users.noreply.github.com> Date: Tue, 18 May 2021 18:04:19 +0200 Subject: [PATCH] Everywhere: Remove calls to internal API SwingUtilities2::shouldIgnore. --- .../github/weisj/darklaf/ui/list/DarkListUIBridge.java | 7 ++++--- .../com/github/weisj/darklaf/ui/table/TableUIBridge.java | 7 ++++--- .../java/com/github/weisj/darklaf/util/SwingUtil.java | 8 ++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java index 9495dfba..cea7171e 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/list/DarkListUIBridge.java @@ -46,6 +46,7 @@ import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.LazyActionMap; import com.github.weisj.darklaf.util.PropertyKey; import com.github.weisj.darklaf.util.PropertyUtil; +import com.github.weisj.darklaf.util.SwingUtil; /** * An extensible implementation of {@code ListUI}. @@ -2469,7 +2470,7 @@ public abstract class DarkListUIBridge extends BasicListUI { public void mouseClicked(final MouseEvent e) {} public void mousePressed(final MouseEvent e) { - if (SwingUtilities2.shouldIgnore(e, list)) { + if (SwingUtil.shouldIgnore(e, list)) { return; } @@ -2562,7 +2563,7 @@ public abstract class DarkListUIBridge extends BasicListUI { } public void mouseReleased(final MouseEvent e) { - if (SwingUtilities2.shouldIgnore(e, list)) { + if (SwingUtil.shouldIgnore(e, list)) { return; } @@ -2591,7 +2592,7 @@ public abstract class DarkListUIBridge extends BasicListUI { } public void mouseDragged(final MouseEvent e) { - if (SwingUtilities2.shouldIgnore(e, list)) { + if (SwingUtil.shouldIgnore(e, list)) { return; } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java index c2510a5f..427db94d 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java @@ -43,6 +43,7 @@ import sun.swing.SwingUtilities2; import com.github.weisj.darklaf.ui.DragRecognitionSupport; import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.PropertyUtil; +import com.github.weisj.darklaf.util.SwingUtil; /** The type Table ui bridge. */ public abstract class TableUIBridge extends BasicTableUI { @@ -573,7 +574,7 @@ public abstract class TableUIBridge extends BasicTableUI { public void mouseClicked(final MouseEvent e) {} public void mousePressed(final MouseEvent e) { - if (SwingUtilities2.shouldIgnore(e, table)) { + if (SwingUtil.shouldIgnore(e, table)) { return; } @@ -607,7 +608,7 @@ public abstract class TableUIBridge extends BasicTableUI { } public void mouseReleased(final MouseEvent e) { - if (SwingUtilities2.shouldIgnore(e, table)) { + if (SwingUtil.shouldIgnore(e, table)) { return; } @@ -855,7 +856,7 @@ public abstract class TableUIBridge extends BasicTableUI { } public void mouseDragged(final MouseEvent e) { - if (SwingUtilities2.shouldIgnore(e, table)) { + if (SwingUtil.shouldIgnore(e, table)) { return; } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/SwingUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/SwingUtil.java index 9e322cb7..ad78734b 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/SwingUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/SwingUtil.java @@ -24,8 +24,10 @@ package com.github.weisj.darklaf.util; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; +import java.awt.event.MouseEvent; import javax.swing.JComponent; +import javax.swing.SwingUtilities; import sun.swing.SwingUtilities2; @@ -59,4 +61,10 @@ public final class SwingUtil { public static int stringWidth(final JComponent c, final FontMetrics fm, final String string) { return SwingUtilities2.stringWidth(c, fm, string); } + + public static boolean shouldIgnore(final MouseEvent me, final JComponent c) { + return c == null || !c.isEnabled() + || !SwingUtilities.isLeftMouseButton(me) + || me.isConsumed(); + } }