private static void prepareGui ( ) { final String osName = System . getProperty ( "os.name" ) . toLowerCase ( ) ; final boolean isMacOs = osName . startsWith ( "mac os x" ) ; if ( isMacOs ) { System . setProperty ( "apple.laf.useScreenMenuBar" , "true" ) ; // fixes the case on macOS where users use the system menu option to quit rather than // closing a window using the 'x' button. Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { @ Override public void run ( ) { doSavePrefsAndUI ( ) ; } } ) ; } else { // Not macOS, so try applying Nimbus L&F, if available. try { for ( UIManager . LookAndFeelInfo info : UIManager . getInstalledLookAndFeels ( ) ) { if ( "Nimbus" . equals ( info . getName ( ) ) ) { UIManager . setLookAndFeel ( info . getClassName ( ) ) ; break ; } } } catch ( Exception exc ) { log . warn ( "Unable to apply Nimbus look-and-feel due to {}" , exc . toString ( ) ) ; if ( log . isTraceEnabled ( ) ) { exc . printStackTrace ( ) ; } } } // misc Gui initialization(s) BAMutil . setResourcePath ( "/resources/nj22/ui/icons/" ) ; // Setting up a font metrics object triggers one of the most time-wasting steps of GUI set up. // We do it now before trying to create the splash or tools interface. SwingUtilities . invokeLater ( ( ) -> { final Toolkit tk = Toolkit . getDefaultToolkit ( ) ; final Font f = new Font ( "SansSerif" , Font . PLAIN , 12 ) ; @ SuppressWarnings ( "deprecation" ) final FontMetrics fm = tk . getFontMetrics ( f ) ; } ) ; }
Set look - and - feel .