Browse Source

Fixes checkbox table editor not being clickable the first time.

pull/170/head
weisj 5 years ago
parent
commit
1f8cea20fa
  1. 1
      core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java
  2. 3
      core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableCellEditor.java
  3. 4
      core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/radiobutton/DarkRadioButtonUI.java
  4. 9
      core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java

1
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) { protected int decorationsStyleFromWindow(final Window window, final int windowDecorationsStyle) {
if (windowDecorationsStyle != JRootPane.NONE) return windowDecorationsStyle; if (windowDecorationsStyle != JRootPane.NONE) return windowDecorationsStyle;
if (DarkUIUtil.isUndecorated(window)) return JRootPane.NONE;
if (window instanceof JFrame) return JRootPane.FRAME; if (window instanceof JFrame) return JRootPane.FRAME;
if (window instanceof JDialog) return JRootPane.PLAIN_DIALOG; if (window instanceof JDialog) return JRootPane.PLAIN_DIALOG;
return windowDecorationsStyle; return windowDecorationsStyle;

3
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 (anEvent instanceof KeyEvent) {
if (DarkTableUI.ignoreKeyCodeOnEdit((KeyEvent) anEvent, table)) return false; 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(); Point p = ((MouseEvent) anEvent).getPoint();
int row = table.rowAtPoint(p); int row = table.rowAtPoint(p);
int col = table.columnAtPoint(p); int col = table.columnAtPoint(p);
@ -206,6 +206,7 @@ public class DarkTableCellEditor extends DefaultCellEditor {
p.y -= rect.y; p.y -= rect.y;
Component editor = getBooleanEditor(table).getTableCellEditorComponent(table, true, Component editor = getBooleanEditor(table).getTableCellEditorComponent(table, true,
false, row, col); false, row, col);
editor.setBounds(rect);
return editor.contains(p); return editor.contains(p);
} }
} }

4
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 @Override
public boolean contains(final JComponent c, final int x, final int y) { public boolean contains(final JComponent c, final int x, final int y) {
if (hitArea == null || (hitArea.isEmpty() && c instanceof JRadioButton)) { if (hitArea == null || (hitArea.isEmpty()) && c instanceof JToggleButton) {
layout((JRadioButton) c, c.getFontMetrics(c.getFont())); layout((JToggleButton) c, c.getFontMetrics(c.getFont()));
} }
return hitArea.contains(x, y); return hitArea.contains(x, y);
} }

9
core/src/main/java/com/github/weisj/darklaf/util/DarkUIUtil.java

@ -374,4 +374,13 @@ public final class DarkUIUtil {
return false; 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;
}
} }

Loading…
Cancel
Save