Browse Source

moved initialization of base Laf to own method.

Signed-off-by: weisj <weisj@arcor.de>
pull/60/head
weisj 5 years ago
parent
commit
06ba14f88d
  1. 14
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

14
core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -28,7 +28,6 @@ import com.github.weisj.darklaf.platform.JNIDecorations;
import com.github.weisj.darklaf.platform.SystemInfo; import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.util.ReflectiveWarningSuppressor;
import sun.awt.AppContext; import sun.awt.AppContext;
import javax.swing.*; import javax.swing.*;
@ -55,31 +54,36 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
private static final Logger LOGGER = Logger.getLogger(DarkLaf.class.getName()); private static final Logger LOGGER = Logger.getLogger(DarkLaf.class.getName());
private static final String NAME = "Darklaf"; private static final String NAME = "Darklaf";
private BasicLookAndFeel base; private final BasicLookAndFeel base;
/** /**
* Create Custom Darcula LaF. * Create Custom Darcula LaF.
*/ */
public DarkLaf() { public DarkLaf() {
LafManager.getTheme().beforeInstall(); LafManager.getTheme().beforeInstall();
base = getBase();
}
private BasicLookAndFeel getBase() {
BasicLookAndFeel baseLaf;
if (SystemInfo.isWindows || SystemInfo.isLinux) { if (SystemInfo.isWindows || SystemInfo.isLinux) {
base = new MetalLookAndFeel(); baseLaf = new MetalLookAndFeel();
} else { } else {
final String systemLafClassName = UIManager.getSystemLookAndFeelClassName(); final String systemLafClassName = UIManager.getSystemLookAndFeelClassName();
final LookAndFeel currentLaf = UIManager.getLookAndFeel(); final LookAndFeel currentLaf = UIManager.getLookAndFeel();
if (currentLaf != null && systemLafClassName.equals(currentLaf.getClass().getName())) { if (currentLaf != null && systemLafClassName.equals(currentLaf.getClass().getName())) {
base = currentOrFallback(currentLaf); baseLaf = currentOrFallback(currentLaf);
} else { } else {
try { try {
UIManager.setLookAndFeel(systemLafClassName); UIManager.setLookAndFeel(systemLafClassName);
base = currentOrFallback(UIManager.getLookAndFeel()); baseLaf = currentOrFallback(UIManager.getLookAndFeel());
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e.getStackTrace()); LOGGER.log(Level.SEVERE, e.getMessage(), e.getStackTrace());
throw new IllegalStateException("Could not load base LaF class." + e.getMessage()); throw new IllegalStateException("Could not load base LaF class." + e.getMessage());
} }
} }
} }
return baseLaf;
} }
private BasicLookAndFeel currentOrFallback(final LookAndFeel currentLaf) { private BasicLookAndFeel currentOrFallback(final LookAndFeel currentLaf) {

Loading…
Cancel
Save