summaryrefslogtreecommitdiffstats
path: root/dozentenmodul
diff options
context:
space:
mode:
authorJonathan Bauer2018-11-28 11:12:08 +0100
committerJonathan Bauer2018-11-28 11:12:08 +0100
commit7480eecef72de710b8468ae04d2d2ef3e919b3c6 (patch)
treef53aac2d086b896dbb06e63a36b8672deef20ec8 /dozentenmodul
parent[client] save L&F if the fallback to GTK was used (diff)
downloadtutor-module-7480eecef72de710b8468ae04d2d2ef3e919b3c6.tar.gz
tutor-module-7480eecef72de710b8468ae04d2d2ef3e919b3c6.tar.xz
tutor-module-7480eecef72de710b8468ae04d2d2ef3e919b3c6.zip
[client] fix NPE on missing L&F config
Diffstat (limited to 'dozentenmodul')
-rwxr-xr-xdozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ConfigWindow.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ConfigWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ConfigWindow.java
index 4637b839..c8c0d9d0 100755
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ConfigWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ConfigWindow.java
@@ -7,6 +7,7 @@ import java.util.Enumeration;
import javax.swing.AbstractButton;
import javax.swing.JRadioButton;
+import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -29,7 +30,7 @@ public class ConfigWindow extends ConfigWindowLayout implements UiFeedback, Acti
private final static Logger LOGGER = Logger.getLogger(ConfigWindow.class);
private SatelliteUserConfig userConfig = null;
- private JRadioButton selectedLookAndFeel;
+ private JRadioButton selectedLookAndFeel = null;
public ConfigWindow(Window modalParent) {
super(modalParent);
@@ -80,11 +81,17 @@ public class ConfigWindow extends ConfigWindowLayout implements UiFeedback, Acti
// set font scaling as saved in config
sldFontSize.setValue(Config.getFontScaling());
sldFontSize.addChangeListener(changeListener);
-
// -- Look And Feel --
for (Enumeration<AbstractButton> btn = btnGroupLookAndFeel.getElements(); btn.hasMoreElements();) {
final JRadioButton b = (JRadioButton) btn.nextElement();
- if (b.getToolTipText().equals(Config.getLookAndFeel())) {
+ if (Config.getLookAndFeel() != null && !Config.getLookAndFeel().isEmpty()) {
+ if (b.getToolTipText().equals(Config.getLookAndFeel())) {
+ selectedLookAndFeel = b;
+ b.setSelected(true);
+ }
+ }
+ // check if we set from the config, if not fall back to system look and feel
+ if (selectedLookAndFeel == null && b.getToolTipText().equals(UIManager.getSystemLookAndFeelClassName())) {
selectedLookAndFeel = b;
b.setSelected(true);
}
@@ -96,6 +103,10 @@ public class ConfigWindow extends ConfigWindowLayout implements UiFeedback, Acti
}
});
}
+ if (selectedLookAndFeel == null) {
+ // non-critical but log it anyways
+ LOGGER.error("Failed to detect the current look & feel theme.");
+ }
// Transfer connection count
sldConnections.setValue(Config.getTransferConnectionCount());