#2509 Tuner frequency control highlight color adapts to color theme (#2510)

Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
Denny Sheirer
2026-10-20 03:46:53 -04:00
committed by GitHub
parent c0a96f94fb
commit b0428a1d8b

View File

@@ -45,6 +45,7 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.UIManager;
/** /**
* Custom frequency controller for displaying or editing frequency values in MHz. * Custom frequency controller for displaying or editing frequency values in MHz.
@@ -556,19 +557,20 @@ public class JFrequencyControl extends JPanel implements ISourceEventProcessor
@Override @Override
public void mouseEntered(MouseEvent e) public void mouseEntered(MouseEvent e)
{ {
Digit.this.setBackground(mHighlightColor); Color bg = UIManager.getColor("TextField.selectionBackground");
repaint(); Color fg = UIManager.getColor("TextField.selectionForeground");
} Digit.this.setBackground(bg != null ? bg : Color.YELLOW);
Digit.this.setForeground(fg != null ? fg : Color.BLACK);
repaint(); }
@Override @Override
public void mouseExited(MouseEvent e) public void mouseExited(MouseEvent e)
{ {
//Restore the LAF text-field background rather than hardcoding white so the digit Color bg = UIManager.getColor("TextField.background");
//cells match the active theme when the mouse leaves. Color fg = UIManager.getColor("TextField.foreground");
Color textBg = javax.swing.UIManager.getColor("TextField.background"); Digit.this.setBackground(bg != null ? bg : Color.WHITE);
Digit.this.setBackground(textBg != null ? textBg : Color.WHITE); Digit.this.setForeground(fg != null ? fg : Color.BLACK);
repaint(); repaint(); }
}
@Override @Override
public void mouseWheelMoved(MouseWheelEvent e) public void mouseWheelMoved(MouseWheelEvent e)