Skip to content

Commit

Permalink
Try to avoid GTK Look&Feel on OpenJDK #393 #638
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb committed Apr 5, 2016
1 parent 93fdb02 commit 553aad3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
26 changes: 16 additions & 10 deletions src/main/java/net/sf/jabref/JabRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,17 +532,26 @@ private Optional<ParserResult> fetch(String fetchCommand) {
private void setLookAndFeel() {
try {
String lookFeel;
String systemLnF = UIManager.getSystemLookAndFeelClassName();
String systemLookFeel = UIManager.getSystemLookAndFeelClassName();

if (Globals.prefs.getBoolean(JabRefPreferences.USE_DEFAULT_LOOK_AND_FEEL)) {
// Use system Look & Feel by default
lookFeel = systemLnF;
lookFeel = systemLookFeel;
} else {
lookFeel = Globals.prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL);
}

// At all cost, avoid ending up with the Metal look and feel:
if ("javax.swing.plaf.metal.MetalLookAndFeel".equals(lookFeel)) {
// Problems with OpenJDK and GTK L&F
// See https://github.com/JabRef/jabref/issues/393, https://github.com/JabRef/jabref/issues/393
// TODO: Still open if this also affects OracleJDK
if (System.getProperty("java.runtime.name").contains("OpenJDK")) {
// Metal L&F
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
// notify the user
JOptionPane.showMessageDialog(jrf,
"There seem to be problems with OpenJDK and the default GTK Look&Feel. Using Metal L&F instead. Change to another L&F with caution.",
Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE);
} else if (UIManager.getCrossPlatformLookAndFeelClassName().equals(lookFeel)) {
// Otherwise try to avoid ending up with the ugly Metal L&F
Plastic3DLookAndFeel lnf = new Plastic3DLookAndFeel();
Plastic3DLookAndFeel.setCurrentTheme(new SkyBluer());
com.jgoodies.looks.Options.setPopupDropShadowEnabled(true);
Expand All @@ -553,9 +562,9 @@ private void setLookAndFeel() {
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
UnsupportedLookAndFeelException e) {
// specified look and feel does not exist on the classpath, so use system l&f
UIManager.setLookAndFeel(systemLnF);
UIManager.setLookAndFeel(systemLookFeel);
// also set system l&f as default
Globals.prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, systemLnF);
Globals.prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, systemLookFeel);
// notify the user
JOptionPane.showMessageDialog(JabRef.jrf,
Localization
Expand Down Expand Up @@ -598,9 +607,6 @@ private void openWindow(List<ParserResult> loaded) {
PreferencesMigrations.upgradeSortOrder();
PreferencesMigrations.upgradeFaultyEncodingStrings();

// Set up custom or default icon theme:
// This is now done at processArguments

// This property is set to make the Mac OSX Java VM move the menu bar to
// the top of the screen, where Mac users expect it to be.
System.setProperty("apple.laf.useScreenMenuBar", "true");
Expand Down
12 changes: 1 addition & 11 deletions src/main/java/net/sf/jabref/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,37 +461,27 @@ private JabRefPreferences() {
defaults.put(BIBLATEX_DEFAULT_MODE, false);

if (OS.OS_X) {
//defaults.put(JabRefPreferences.PDFVIEWER, "/Applications/Preview.app");
//defaults.put(JabRefPreferences.PSVIEWER, "/Applications/Preview.app");
//defaults.put("htmlviewer", "/Applications/Safari.app");
defaults.put(EMACS_PATH, "emacsclient");
defaults.put(EMACS_23, true);
defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-n -e");
defaults.put(FONT_FAMILY, "SansSerif");
defaults.put(WIN_LOOK_AND_FEEL, UIManager.getSystemLookAndFeelClassName());

} else if (OS.WINDOWS) {
//defaults.put(JabRefPreferences.PDFVIEWER, "cmd.exe /c start /b");
//defaults.put(JabRefPreferences.PSVIEWER, "cmd.exe /c start /b");
//defaults.put("htmlviewer", "cmd.exe /c start /b");
defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.looks.windows.WindowsLookAndFeel");
defaults.put(EMACS_PATH, "emacsclient.exe");
defaults.put(EMACS_23, true);
defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-n -e");
defaults.put(FONT_FAMILY, "Arial");

} else {
//defaults.put(JabRefPreferences.PDFVIEWER, "evince");
//defaults.put(JabRefPreferences.PSVIEWER, "gv");
//defaults.put("htmlviewer", "firefox");
// Linux
defaults.put(WIN_LOOK_AND_FEEL, "com.jgoodies.plaf.plastic.Plastic3DLookAndFeel");
defaults.put(FONT_FAMILY, "SansSerif");

// linux
defaults.put(EMACS_PATH, "gnuclient");
defaults.put(EMACS_23, false);
defaults.put(EMACS_ADDITIONAL_PARAMETERS, "-batch -eval");

}
defaults.put(PUSH_TO_APPLICATION, "TeXstudio");

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/sf/jabref/Jdktest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.sf.jabref;

public class Jdktest {
}

0 comments on commit 553aad3

Please sign in to comment.