Use static UI color caching

This commit is contained in:
SiboVG 2023-09-24 22:39:13 +02:00
parent 4f8611ac58
commit 336299e4ba
2 changed files with 21 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.components.DescriptionArea;
@ -17,6 +18,7 @@ import net.sf.openrocket.gui.components.StyledLabel.Style;
import net.sf.openrocket.gui.components.URLLabel;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.Icons;
import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BuildProperties;
@ -85,6 +87,12 @@ public class AboutDialog extends JDialog {
"Enhanced components database for OpenRocket" + href("https://github.com/dbcook/openrocket-database", true, true) +
"</center></html>";
private static Border border;
static {
initColors();
}
private String href(String url, boolean delimiters, boolean leadingSpace) {
return (leadingSpace ? " " : "") + (delimiters ? "(" : "") + "<a href=\"" + url + "\">" + url + "</a>" + (delimiters ? ")" : "");
}
@ -142,7 +150,7 @@ public class AboutDialog extends JDialog {
DescriptionArea info = new DescriptionArea(5);
info.setBorder(GUIUtil.getUITheme().getBorder());
info.setBorder(border);
info.setText(CREDITS);
info.setTextFont(UIManager.getFont("Label.font"));
panel.add(info, "newline, width 10px, height 250lp, pushy, grow, spanx, wrap para");
@ -171,4 +179,13 @@ public class AboutDialog extends JDialog {
GUIUtil.setDisposableDialogOptions(this, close);
}
private static void initColors() {
updateColors();
UITheme.Theme.addUIThemeChangeListener(AboutDialog::updateColors);
}
private static void updateColors() {
border = GUIUtil.getUITheme().getBorder();
}
}

View File

@ -66,6 +66,7 @@ class SimulationOptionsPanel extends JPanel {
JMenu extensionMenuCopyExtension;
private static Color textColor;
private static Color dimTextColor;
private static Border border;
static {
@ -232,6 +233,7 @@ class SimulationOptionsPanel extends JPanel {
private static void updateColors() {
textColor = GUIUtil.getUITheme().getTextColor();
dimTextColor = GUIUtil.getUITheme().getDimTextColor();
border = GUIUtil.getUITheme().getBorder();
}
@ -349,7 +351,7 @@ class SimulationOptionsPanel extends JPanel {
if (simulation.getSimulationExtensions().isEmpty()) {
StyledLabel l = new StyledLabel(trans.get("simedtdlg.SimExt.noExtensions"), Style.ITALIC);
l.setForeground(GUIUtil.getUITheme().getDimTextColor());
l.setForeground(dimTextColor);
currentExtensions.add(l, "growx, pad 5 5 5 5, wrap");
} else {
for (SimulationExtension e : simulation.getSimulationExtensions()) {