Use static UI color caching
This commit is contained in:
parent
4f8611ac58
commit
336299e4ba
@ -9,6 +9,7 @@ import javax.swing.JFrame;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.gui.components.DescriptionArea;
|
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.components.URLLabel;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.Icons;
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
|
import net.sf.openrocket.gui.util.UITheme;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.BuildProperties;
|
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) +
|
"Enhanced components database for OpenRocket" + href("https://github.com/dbcook/openrocket-database", true, true) +
|
||||||
"</center></html>";
|
"</center></html>";
|
||||||
|
|
||||||
|
private static Border border;
|
||||||
|
|
||||||
|
static {
|
||||||
|
initColors();
|
||||||
|
}
|
||||||
|
|
||||||
private String href(String url, boolean delimiters, boolean leadingSpace) {
|
private String href(String url, boolean delimiters, boolean leadingSpace) {
|
||||||
return (leadingSpace ? " " : "") + (delimiters ? "(" : "") + "<a href=\"" + url + "\">" + url + "</a>" + (delimiters ? ")" : "");
|
return (leadingSpace ? " " : "") + (delimiters ? "(" : "") + "<a href=\"" + url + "\">" + url + "</a>" + (delimiters ? ")" : "");
|
||||||
}
|
}
|
||||||
@ -142,7 +150,7 @@ public class AboutDialog extends JDialog {
|
|||||||
|
|
||||||
|
|
||||||
DescriptionArea info = new DescriptionArea(5);
|
DescriptionArea info = new DescriptionArea(5);
|
||||||
info.setBorder(GUIUtil.getUITheme().getBorder());
|
info.setBorder(border);
|
||||||
info.setText(CREDITS);
|
info.setText(CREDITS);
|
||||||
info.setTextFont(UIManager.getFont("Label.font"));
|
info.setTextFont(UIManager.getFont("Label.font"));
|
||||||
panel.add(info, "newline, width 10px, height 250lp, pushy, grow, spanx, wrap para");
|
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);
|
GUIUtil.setDisposableDialogOptions(this, close);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void initColors() {
|
||||||
|
updateColors();
|
||||||
|
UITheme.Theme.addUIThemeChangeListener(AboutDialog::updateColors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void updateColors() {
|
||||||
|
border = GUIUtil.getUITheme().getBorder();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ class SimulationOptionsPanel extends JPanel {
|
|||||||
JMenu extensionMenuCopyExtension;
|
JMenu extensionMenuCopyExtension;
|
||||||
|
|
||||||
private static Color textColor;
|
private static Color textColor;
|
||||||
|
private static Color dimTextColor;
|
||||||
private static Border border;
|
private static Border border;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -232,6 +233,7 @@ class SimulationOptionsPanel extends JPanel {
|
|||||||
|
|
||||||
private static void updateColors() {
|
private static void updateColors() {
|
||||||
textColor = GUIUtil.getUITheme().getTextColor();
|
textColor = GUIUtil.getUITheme().getTextColor();
|
||||||
|
dimTextColor = GUIUtil.getUITheme().getDimTextColor();
|
||||||
border = GUIUtil.getUITheme().getBorder();
|
border = GUIUtil.getUITheme().getBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +351,7 @@ class SimulationOptionsPanel extends JPanel {
|
|||||||
|
|
||||||
if (simulation.getSimulationExtensions().isEmpty()) {
|
if (simulation.getSimulationExtensions().isEmpty()) {
|
||||||
StyledLabel l = new StyledLabel(trans.get("simedtdlg.SimExt.noExtensions"), Style.ITALIC);
|
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");
|
currentExtensions.add(l, "growx, pad 5 5 5 5, wrap");
|
||||||
} else {
|
} else {
|
||||||
for (SimulationExtension e : simulation.getSimulationExtensions()) {
|
for (SimulationExtension e : simulation.getSimulationExtensions()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user