Fix so scrollbars and buttons aren't messed up when skin changed

This commit is contained in:
drdev
2013-09-03 22:47:28 +00:00
parent cfed3ee53a
commit b9d5cc4ae7

View File

@@ -1834,16 +1834,19 @@ public enum FSkin {
*/ */
private static class ForgeLookAndFeel { //needs to live in FSkin for access to skin colors private static class ForgeLookAndFeel { //needs to live in FSkin for access to skin colors
private Color FORE_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT).color; private static boolean onInit = true;
private Color BACK_COLOR = FSkin.getColor(FSkin.Colors.CLR_THEME2).color; private static boolean isMetalLafSet = false;
private Color HIGHLIGHT_COLOR = BACK_COLOR.brighter();
private Border LINE_BORDER = BorderFactory.createLineBorder(FORE_COLOR.darker(), 1); private final Color FORE_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT).color;
private Border EMPTY_BORDER = BorderFactory.createEmptyBorder(2,2,2,2); private final Color BACK_COLOR = FSkin.getColor(FSkin.Colors.CLR_THEME2).color;
private final Color HIGHLIGHT_COLOR = BACK_COLOR.brighter();
private final Border LINE_BORDER = BorderFactory.createLineBorder(FORE_COLOR.darker(), 1);
private final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(2, 2, 2, 2);
/** /**
* Sets the look and feel of the GUI based on the selected Forge theme. * Sets the look and feel of the GUI based on the selected Forge theme.
*/ */
public void setForgeLookAndFeel(JFrame appFrame) { private void setForgeLookAndFeel(final JFrame appFrame) {
if (isUIManagerEnabled()) { if (isUIManagerEnabled()) {
if (setMetalLookAndFeel(appFrame)) { if (setMetalLookAndFeel(appFrame)) {
setMenusLookAndFeel(); setMenusLookAndFeel();
@@ -1852,6 +1855,7 @@ public enum FSkin {
setButtonLookAndFeel(); setButtonLookAndFeel();
} }
} }
onInit = false;
} }
/** /**
@@ -1861,7 +1865,7 @@ public enum FSkin {
* not support various settings (eg. combobox background color). * not support various settings (eg. combobox background color).
*/ */
private boolean setMetalLookAndFeel(JFrame appFrame) { private boolean setMetalLookAndFeel(JFrame appFrame) {
boolean isMetalLafSet = false; if (onInit) { //only attempt to set Metal Look and Feel the first time
try { try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.updateComponentTreeUI(appFrame); SwingUtilities.updateComponentTreeUI(appFrame);
@@ -1870,6 +1874,7 @@ public enum FSkin {
// Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log. // Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
e.printStackTrace(); e.printStackTrace();
} }
}
return isMetalLafSet; return isMetalLafSet;
} }
@@ -1974,6 +1979,5 @@ public enum FSkin {
gradients.add(bottom); gradients.add(bottom);
return gradients; return gradients;
} }
} }
} }