From aaa3a0849ea9235954f3d95cdcdcab5c871bbca2 Mon Sep 17 00:00:00 2001 From: weisj Date: Sun, 3 May 2020 18:55:32 +0200 Subject: [PATCH] Fixed paint creeping for text components. --- .../github/weisj/darklaf/ui/text/DarkTextUI.java | 14 +++++++------- .../com/github/weisj/darklaf/util/DarkUIUtil.java | 6 ++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java index 9c86ed15..ebe9fd92 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java @@ -46,8 +46,8 @@ import com.github.weisj.darklaf.graphics.GraphicsContext; import com.github.weisj.darklaf.graphics.GraphicsUtil; import com.github.weisj.darklaf.graphics.PaintUtil; import com.github.weisj.darklaf.ui.list.DarkListUI; -import com.github.weisj.darklaf.ui.table.DarkTableCellBorder; import com.github.weisj.darklaf.ui.table.DarkTableUI; +import com.github.weisj.darklaf.ui.table.TextTableCellEditorBorder; import com.github.weisj.darklaf.ui.text.action.DarkKeyTypedAction; import com.github.weisj.darklaf.ui.text.action.ToggleInsertAction; import com.github.weisj.darklaf.ui.tree.DarkTreeUI; @@ -197,9 +197,12 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi @Override protected void paintBackground(final Graphics g) { final Container parent = getRelevantParent(editor); - if (parent != null && parent.isOpaque() && !editor.isEnabled()) { + if (parent != null) { g.setColor(parent.getBackground()); g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); + } + + if (!editor.isEnabled()) { return; } @@ -209,16 +212,13 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi || PropertyUtil.getBooleanProperty(editor, KEY_IS_TABLE_EDITOR)) { g.setColor(getBackground(editor)); g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); - } else if (parent != null && parent.isOpaque()) { - g.setColor(parent.getBackground()); - g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); } } Border border = editor.getBorder(); if (border instanceof DarkTextBorder) { paintBorderBackground((Graphics2D) g, editor); - } else if (border instanceof DarkTableCellBorder) { + } else if (border instanceof TextTableCellEditorBorder) { g.setColor(editor.getBackground()); g.fillRect(0, 0, editor.getWidth(), editor.getHeight()); } else if (border != null && !(border instanceof DarkPlainTextBorder)) { @@ -242,7 +242,7 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi } else if (parent instanceof JComboBox) { parent = parent.getParent(); } - return parent; + return DarkUIUtil.getOpaqueParent(parent); } @Override 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 f8c38393..ee7e53f5 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 @@ -394,4 +394,10 @@ public final class DarkUIUtil { } return false; } + + public static Container getOpaqueParent(final Container parent) { + Container p; + for (p = parent; p != null && !p.isOpaque(); p = p.getParent()) {} + return p; + } }