From 1f8cea20fa36899826d218ac6c4220e2b8ded95e Mon Sep 17 00:00:00 2001 From: weisj Date: Wed, 29 Apr 2020 15:41:32 +0200 Subject: [PATCH] Fixes checkbox table editor not being clickable the first time. --- .../github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java | 1 + .../weisj/darklaf/ui/table/DarkTableCellEditor.java | 3 ++- .../ui/togglebutton/radiobutton/DarkRadioButtonUI.java | 4 ++-- .../java/com/github/weisj/darklaf/util/DarkUIUtil.java | 9 +++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java index f9f55b7c..edf485ee 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java @@ -109,6 +109,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener protected int decorationsStyleFromWindow(final Window window, final int windowDecorationsStyle) { if (windowDecorationsStyle != JRootPane.NONE) return windowDecorationsStyle; + if (DarkUIUtil.isUndecorated(window)) return JRootPane.NONE; if (window instanceof JFrame) return JRootPane.FRAME; if (window instanceof JDialog) return JRootPane.PLAIN_DIALOG; return windowDecorationsStyle; diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java index 157587ae..3f5c2f25 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java @@ -194,7 +194,7 @@ public class DarkTableCellEditor extends DefaultCellEditor { if (anEvent instanceof KeyEvent) { if (DarkTableUI.ignoreKeyCodeOnEdit((KeyEvent) anEvent, table)) return false; } - if (DarkTableCellRenderer.isBooleanRenderingEnabled(table) && anEvent instanceof MouseEvent) { + if (anEvent instanceof MouseEvent && DarkTableCellRenderer.isBooleanRenderingEnabled(table)) { Point p = ((MouseEvent) anEvent).getPoint(); int row = table.rowAtPoint(p); int col = table.columnAtPoint(p); @@ -206,6 +206,7 @@ public class DarkTableCellEditor extends DefaultCellEditor { p.y -= rect.y; Component editor = getBooleanEditor(table).getTableCellEditorComponent(table, true, false, row, col); + editor.setBounds(rect); return editor.contains(p); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java index f2c06565..1658f6bc 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java @@ -252,8 +252,8 @@ public class DarkRadioButtonUI extends MetalRadioButtonUI implements PropertyCha @Override public boolean contains(final JComponent c, final int x, final int y) { - if (hitArea == null || (hitArea.isEmpty() && c instanceof JRadioButton)) { - layout((JRadioButton) c, c.getFontMetrics(c.getFont())); + if (hitArea == null || (hitArea.isEmpty()) && c instanceof JToggleButton) { + layout((JToggleButton) c, c.getFontMetrics(c.getFont())); } return hitArea.contains(x, y); } diff --git a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java index 48d3c0aa..f9ab838f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java @@ -374,4 +374,13 @@ public final class DarkUIUtil { return false; } } + + public static boolean isUndecorated(final Window window) { + if (window instanceof Frame) { + return ((Frame) window).isUndecorated(); + } else if (window instanceof Dialog) { + return ((Dialog) window).isUndecorated(); + } + return false; + } }