From 3f0b5e00459c9e8c30b1f5a033d7fed7133ad49f Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Wed, 24 Apr 2019 01:51:14 +0430 Subject: [PATCH] Use Nimbus theme on the applet See https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html --- CuckooChess/src/main/java/gui/AppletGUI.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CuckooChess/src/main/java/gui/AppletGUI.java b/CuckooChess/src/main/java/gui/AppletGUI.java index 947e74c..1802888 100644 --- a/CuckooChess/src/main/java/gui/AppletGUI.java +++ b/CuckooChess/src/main/java/gui/AppletGUI.java @@ -23,6 +23,7 @@ import guibase.GUIInterface; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; +import javax.swing.UIManager; import chess.ComputerPlayer; import chess.Move; @@ -55,10 +56,23 @@ public class AppletGUI extends javax.swing.JApplet implements GUIInterface { } } + private static void setNimbusAsTheme() { + try { + for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (Exception ignore) { + } + } + /** * Entry point for the GUI version of the chess program. */ public static void main(String[] args) { + setNimbusAsTheme(); javax.swing.JApplet theApplet = new AppletGUI(); theApplet.init(); javax.swing.JFrame window = new javax.swing.JFrame(ComputerPlayer.engineName);