Use Nimbus theme on the applet

See https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html
This commit is contained in:
Ebrahim Byagowi 2019-04-24 01:51:14 +04:30 committed by Peter Osterlund
parent 69206ef89b
commit 3f0b5e0045

View File

@ -23,6 +23,7 @@ import guibase.GUIInterface;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import chess.ComputerPlayer; import chess.ComputerPlayer;
import chess.Move; 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. * Entry point for the GUI version of the chess program.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
setNimbusAsTheme();
javax.swing.JApplet theApplet = new AppletGUI(); javax.swing.JApplet theApplet = new AppletGUI();
theApplet.init(); theApplet.init();
javax.swing.JFrame window = new javax.swing.JFrame(ComputerPlayer.engineName); javax.swing.JFrame window = new javax.swing.JFrame(ComputerPlayer.engineName);