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(); + } }