From 5a1402bc1df944b9df1c675f2d2816d03ba574a8 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Sun, 22 Mar 2020 19:41:56 +0100 Subject: [PATCH] Fixed dark theme on KDE --- .../java/org/insa/graphs/gui/MainWindow.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/be-graphes-gui/src/main/java/org/insa/graphs/gui/MainWindow.java b/be-graphes-gui/src/main/java/org/insa/graphs/gui/MainWindow.java index 41ff400..0e2271e 100644 --- a/be-graphes-gui/src/main/java/org/insa/graphs/gui/MainWindow.java +++ b/be-graphes-gui/src/main/java/org/insa/graphs/gui/MainWindow.java @@ -72,6 +72,7 @@ import org.insa.graphs.model.io.BinaryPathReader; import org.insa.graphs.model.io.GraphReader; import org.insa.graphs.model.io.MapMismatchException; + public class MainWindow extends JFrame { /** @@ -82,7 +83,7 @@ public class MainWindow extends JFrame { /** * */ - private static final String WINDOW_TITLE = "BE Graphes INSA"; + private static final String WINDOW_TITLE = "CC la famille"; /** * @@ -344,7 +345,7 @@ public class MainWindow extends JFrame { JTextArea infoPanel = new JTextArea(); infoPanel.setMinimumSize(new Dimension(200, 50)); - infoPanel.setBackground(Color.WHITE); +// infoPanel.setBackground(Color.WHITE); infoPanel.setLineWrap(true); infoPanel.setEditable(false); this.logStream = new StreamCapturer(infoPanel); @@ -377,7 +378,7 @@ public class MainWindow extends JFrame { mainPanel.setResizeWeight(0.8); mainPanel.setDividerSize(5); - mainPanel.setBackground(Color.WHITE); +// mainPanel.setBackground(Color.WHITE); mainPanel.setLeftComponent(openPanel); mainPanel.setRightComponent(rightComponent); this.add(mainPanel, BorderLayout.CENTER); @@ -844,7 +845,16 @@ public class MainWindow extends JFrame { // Try to set system look and feel. try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + boolean isThemeSet = false; + for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { + if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(info.getClassName())) { + UIManager.setLookAndFeel(info.getClassName()); + isThemeSet = true; + break; + } + } + if (!isThemeSet) + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { }