…
ah, you don’t know …
This MIGHT do the trick (at least it runs on Mac without an error; will need to install Java on Windows and see what happens there):
public static void main(String[] args) {
if (isWindows()) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
javax.swing.UIManager.LookAndFeelInfo[] installedLookAndFeels=javax.swing.UIManager.getInstalledLookAndFeels();
for (int idx=0; idx<installedLookAndFeels.length; idx++)
if ("Nimbus".equals(installedLookAndFeels[idx].getName())) {
javax.swing.UIManager.setLookAndFeel(installedLookAndFeels[idx].getClassName());
break;
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Anagrams.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Anagrams.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Anagrams.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Anagrams.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
} else if (isMac()) {
/* Set the Mac look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* For details see https://alvinalexander.com/blog/post/jfc-swing/mac-osx-specific-property-settings-java-swing-applications/
*/
try
{
// set the brushed metal look and feel, if desired
System.setProperty("apple.awt.brushMetalLook", "true");
// use the mac system menu bar
System.setProperty("apple.laf.useScreenMenuBar", "true");
// set the "About" menu item name
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "WikiStar");
// use smoother fonts
System.setProperty("apple.awt.textantialiasing", "true");
// ref: http://developer.apple.com/releasenotes/Java/Java142RNTiger/1_NewFeatures/chapter_2_section_3.html
System.setProperty("apple.awt.graphics.EnableQ2DX","true");
// use the system look and feel
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e)
{
// put your debug code here ...
}
} else if (isUnix()) {
System.out.println("This is Unix or Linux");
} else if (isSolaris()) {
System.out.println("This is Solaris");
} else {
System.out.println("Your OS is not support!!");
}
//</editor-fold>
/* Create and display the form */
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Anagrams().setVisible(true);
}
});
}
private static String OS = System.getProperty("os.name").toLowerCase();
public static boolean isWindows() {
return (OS.indexOf("win") >= 0);
}
public static boolean isMac() {
return (OS.indexOf("mac") >= 0);
}
public static boolean isUnix() {
return (OS.indexOf("nix") >= 0
|| OS.indexOf("nux") >= 0
|| OS.indexOf("aix") > 0);
}
public static boolean isSolaris() {
return (OS.indexOf("sunos") >= 0);
}
So far I’m quite pleasantly surprised by Java …