From fa85fd74798e89d048cebfb6806ad9a8e0b65ee1 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Wed, 21 Jul 2021 23:20:42 +0200 Subject: [PATCH] Better Hex Editor in Dark Mode --- .../club/bytecodeviewer/gui/hexviewer/JHexEditor.java | 9 +++++---- .../bytecodeviewer/gui/hexviewer/JHexEditorASCII.java | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditor.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditor.java index db381ba5..09222aa7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditor.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditor.java @@ -11,6 +11,7 @@ import java.awt.Graphics; import java.awt.Rectangle; import java.awt.event.*; import javax.swing.*; +import the.bytecode.club.bytecodeviewer.Configuration; /** * @author laullon @@ -235,9 +236,9 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe @Override public void paint(Graphics g) { Dimension d = getMinimumSize(); - g.setColor(Color.white); + g.setColor(Configuration.lafTheme.isDark() ? Color.darkGray : Color.white); g.fillRect(0, 0, d.width, d.height); - g.setColor(Color.black); + g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black); g.setFont(font); for (int n = 0; n < textLength; n++) { @@ -297,9 +298,9 @@ public class JHexEditor extends JPanel implements FocusListener, AdjustmentListe public void paint(Graphics g) { Dimension d = getMinimumSize(); - g.setColor(Color.white); + g.setColor(Configuration.lafTheme.isDark() ? Color.darkGray : Color.white); g.fillRect(0, 0, d.width, d.height); - g.setColor(Color.black); + g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black); g.setFont(font); int ini = getInicio(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorASCII.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorASCII.java index 23f2bfa6..fd9e3634 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorASCII.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/hexviewer/JHexEditorASCII.java @@ -9,6 +9,7 @@ import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.JComponent; +import the.bytecode.club.bytecodeviewer.Configuration; /** * @author laullon @@ -65,9 +66,9 @@ public class JHexEditorASCII extends JComponent implements MouseListener, KeyLis debug("paint(" + g + ")"); debug("cursor=" + he.cursor + " buff.length=" + he.buff.length); Dimension d = getMinimumSize(); - g.setColor(Color.white); + g.setColor(Configuration.lafTheme.isDark() ? Color.darkGray : Color.white); g.fillRect(0, 0, d.width, d.height); - g.setColor(Color.black); + g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black); g.setFont(he.font); @@ -87,11 +88,11 @@ public class JHexEditorASCII extends JComponent implements MouseListener, KeyLis else he.cuadro(g, x, y, 1); if (hasFocus()) - g.setColor(Color.white); + g.setColor(Configuration.lafTheme.isDark() ? Color.black : Color.white); else - g.setColor(Color.black); + g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black); } else { - g.setColor(Color.black); + g.setColor(Configuration.lafTheme.isDark() ? Color.white : Color.black); } String s = String.valueOf((char) (he.buff[n] & 0xFF));//"" + new Character((char) he.buff[n]);