Skip to content

Commit fc19411

Browse files
Make log panel more resilient against theme changes
1 parent 2eb1e23 commit fc19411

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/net/pistonmaster/soulfire/client/gui/libs/MessageLogPanel.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public class MessageLogPanel extends JPanel {
8989
new IndependentControlFunctionHandler(),
9090
new ControlStringHandler())
9191
.build();
92+
private static final Color BACKGROUND_COLOR = Color.decode("#090300");
93+
private static final Color DEFAULT_TEXT_COLOR = new Color(204, 204, 204);
9294
private boolean clearText;
9395

9496
public MessageLogPanel(int numLines) {
@@ -99,7 +101,8 @@ public MessageLogPanel(int numLines) {
99101
textComponent.setFont(
100102
new Font(FlatJetBrainsMonoFont.FAMILY, Font.PLAIN, new JLabel().getFont().getSize()));
101103
textComponent.setEditable(true);
102-
textComponent.setBackground(Color.decode("#090300"));
104+
textComponent.setBackground(BACKGROUND_COLOR);
105+
StyleConstants.setForeground(defaultAttributes, DEFAULT_TEXT_COLOR);
103106

104107
var caret = (DefaultCaret) textComponent.getCaret();
105108
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
@@ -162,6 +165,7 @@ private void updateTextComponent() {
162165
var name = attributes.nextElement();
163166
defaultAttributes.removeAttribute(name);
164167
}
168+
StyleConstants.setForeground(defaultAttributes, DEFAULT_TEXT_COLOR);
165169
}
166170
case 1 -> StyleConstants.setBold(defaultAttributes, true);
167171
case 3 -> StyleConstants.setItalic(defaultAttributes, true);
@@ -188,8 +192,7 @@ private void updateTextComponent() {
188192
StyleConstants.setForeground(
189193
defaultAttributes, new Color(44, 181, 233));
190194
case 37, 39 ->
191-
StyleConstants.setForeground(
192-
defaultAttributes, new Color(204, 204, 204));
195+
StyleConstants.setForeground(defaultAttributes, DEFAULT_TEXT_COLOR);
193196
case 38 -> {
194197
var secondArgument =
195198
(int) functionFragment.getArguments().get(1).getValue();

0 commit comments

Comments
 (0)