Skip to content

Commit

Permalink
Fix color issue in dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
zehuanncc committed Apr 13, 2021
1 parent 303ff2f commit 754d97d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BappManifest.bmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Uuid: 0a05afd37da44adca514acef1cdde3b9
ExtensionType: 1
Name: Decoder Improved
RepoName: decoder-improved
ScreenVersion: 1.2.5.1
ScreenVersion: 1.2.6
SerialVersion: 8
MinPlatformVersion: 0
ProOnly: False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
class SendToDecoderImprovedContextMenuFactory implements IContextMenuFactory {
private final Color HIGHLIGHT_COLOR = new Color(0xE58900);
private final Color DEFAULT_COLOR = Color.BLACK;

private MainTab mainTab;

Expand Down Expand Up @@ -114,9 +113,10 @@ private void highlightParentTab() {
if (tabComponent != null) {
JTabbedPane parentTabbedPane = (JTabbedPane) tabComponent.getParent();
int index = parentTabbedPane.indexOfComponent(tabComponent);
Color originalColor = parentTabbedPane.getForegroundAt(index);
parentTabbedPane.setBackgroundAt(index, HIGHLIGHT_COLOR);
Timer timer = new Timer(3000, e -> {
parentTabbedPane.setBackgroundAt(index, DEFAULT_COLOR);
parentTabbedPane.setBackgroundAt(index, originalColor);
});
timer.setRepeats(false);
timer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ JTextArea getTextEditor() {
void updateEditors(DecoderSegmentState dsState) {
lockDocumentEvents = true;
textEditor.setText(dsState.getDisplayString());
textEditor.setForeground(Color.BLACK);
textEditor.setEditable(true);
hexEditor.setData(new ByteArrayEditableData(dsState.getByteArray()));
lockDocumentEvents = false;
Expand Down
17 changes: 15 additions & 2 deletions src/main/trust/nccgroup/decoderimproved/components/DecoderTab.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package trust.nccgroup.decoderimproved.components;

import trust.nccgroup.decoderimproved.Logger;
import trust.nccgroup.decoderimproved.ModificationException;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.nio.ByteBuffer;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
Expand Down Expand Up @@ -158,9 +162,18 @@ private DecoderTabHandle(String title, MainTab mainTab, DecoderTab decoderTab) {
tabNameField = new JTextField(title);
tabNameField.setOpaque(false);
tabNameField.setBorder(null);
tabNameField.setBackground(new Color(0, 0, 0, 0));
tabNameField.setEditable(false);
tabNameField.setCaretColor(Color.BLACK);
// This is to overwrite the change of the border of each tabNameField, which is triggered when the theme is changed in Burp
tabNameField.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("border")) {
tabNameField.removePropertyChangeListener(this);
tabNameField.setBorder(null);
tabNameField.addPropertyChangeListener(this);
}
}
});

this.add(tabNameField);
closeButton = new JButton("✕");
Expand Down

0 comments on commit 754d97d

Please sign in to comment.