< prev index next >
src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -408,5 +408,30 @@
JNF_COCOA_EXIT(env);
return jpt;
}
+
+JNIEXPORT void JNICALL
+Java_sun_lwawt_macosx_CTrayIcon_nativeShowNotification
+(JNIEnv *env, jobject self, jlong model, jobject jcaption, jobject jtext,
+ long nsimage) {
+JNF_COCOA_ENTER(env);
+
+ AWTTrayIcon *icon = jlong_to_ptr(model);
+ NSString *caption = JNFJavaToNSString(env, jcaption);
+ NSString *text = JNFJavaToNSString(env, jtext);
+ NSImage * contentImage = jlong_to_ptr(nsimage);
+
+ [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
+ NSUserNotification *notification = [[NSUserNotification alloc] init];
+ notification.title = caption;
+ notification.informativeText = text;
+ notification.contentImage = contentImage;
+ notification.soundName = NSUserNotificationDefaultSoundName;
+
+ [[NSUserNotificationCenter defaultUserNotificationCenter]
+ deliverNotification:notification];
+ }];
+
+JNF_COCOA_EXIT(env);
+}
< prev index next >