@@ -88,14 +88,24 @@ public class VncViewer implements Runnable {
88
88
public static void setLookAndFeel () {
89
89
try {
90
90
if (os .startsWith ("mac os x" )) {
91
- Class appClass = Class .forName ("com.apple.eawt.Application" );
91
+ String appClassName = new String ("com.apple.eawt.Application" );
92
+ String appMethodName = new String ("getApplication" );
93
+ String setIconMethodName = new String ("setDockIconImage" );
94
+ // JEP-272. Platform-specific Desktop Features are strongly encapsulated
95
+ // in JRE 9 & above, but the API features needed aren't in JRE 8.
96
+ if (Float .parseFloat (System .getProperty ("java.specification.version" )) > 1.8 ) {
97
+ appClassName = new String ("java.awt.Taskbar" );
98
+ appMethodName = new String ("getTaskbar" );
99
+ setIconMethodName = new String ("setIconImage" );
100
+ }
101
+ Class appClass = Class .forName (appClassName );
92
102
Method getApplication =
93
- appClass .getMethod ("getApplication" , (Class [])null );
103
+ appClass .getMethod (appMethodName , (Class [])null );
94
104
Object app = getApplication .invoke (appClass );
95
105
Class paramTypes [] = new Class [1 ];
96
106
paramTypes [0 ] = Image .class ;
97
- Method setDockIconImage =
98
- appClass .getMethod ("setDockIconImage" , paramTypes );
107
+ Method setDockIconImage =
108
+ appClass .getMethod (setIconMethodName , paramTypes );
99
109
setDockIconImage .invoke (app , VncViewer .logoImage );
100
110
}
101
111
// Use Nimbus LookAndFeel if it's available, otherwise fallback
0 commit comments