--- a/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java Tue Jul 31 21:01:56 2012 +0400
+++ b/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java Thu Aug 30 13:11:23 2012 -0700
@@ -27,10 +27,9 @@
import java.awt.*;
import java.awt.peer.SystemTrayPeer;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
import sun.awt.SunToolkit;
import sun.awt.AppContext;
+import sun.awt.AWTAccessor;
import sun.util.logging.PlatformLogger;
public class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListener {
@@ -42,11 +41,6 @@
private volatile boolean available;
private final XMSelection selection = new XMSelection("_NET_SYSTEM_TRAY");
- private static final Method firePropertyChangeMethod =
- XToolkit.getMethod(SystemTray.class, "firePropertyChange", new Class[] {String.class, Object.class, Object.class});
- private static final Method addNotifyMethod = XToolkit.getMethod(TrayIcon.class, "addNotify", null);
- private static final Method removeNotifyMethod = XToolkit.getMethod(TrayIcon.class, "removeNotify", null);
-
private static final int SCREEN = 0;
private static final String SYSTEM_TRAY_PROPERTY_NAME = "systemTray";
private static final XAtom _NET_SYSTEM_TRAY = XAtom.get("_NET_SYSTEM_TRAY_S" + SCREEN);
@@ -157,44 +151,43 @@
return peerInstance;
}
- private void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) {
+ private void firePropertyChange(final String propertyName,
+ final Object oldValue,
+ final Object newValue) {
Runnable runnable = new Runnable() {
public void run() {
- Object[] args = new Object[] {propertyName, oldValue, newValue};
- invokeMethod(firePropertyChangeMethod, target, args);
+ AWTAccessor.getSystemTrayAccessor()
+ .firePropertyChange(target, propertyName, oldValue, newValue);
}
};
invokeOnEachAppContext(runnable);
}
private void createTrayPeers() {
- invokeOnEachTrayIcon(addNotifyMethod);
- }
-
- private void removeTrayPeers() {
- invokeOnEachTrayIcon(removeNotifyMethod);
- }
-
- private void invokeOnEachTrayIcon(final Method method) {
Runnable runnable = new Runnable() {
public void run() {
TrayIcon[] icons = target.getTrayIcons();
- for (TrayIcon ti : icons) {
- invokeMethod(method, ti, (Object[]) null);
+ try {
+ for (TrayIcon ti : icons) {
+ AWTAccessor.getTrayIconAccessor().addNotify(ti);
+ }
+ } catch (AWTException e) {
}
}
};
invokeOnEachAppContext(runnable);
}
- private void invokeMethod(Method method, Object obj, Object[] args) {
- try{
- method.invoke(obj, args);
- } catch (InvocationTargetException e){
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
+ private void removeTrayPeers() {
+ Runnable runnable = new Runnable() {
+ public void run() {
+ TrayIcon[] icons = target.getTrayIcons();
+ for (TrayIcon ti : icons) {
+ AWTAccessor.getTrayIconAccessor().removeNotify(ti);
+ }
+ }
+ };
+ invokeOnEachAppContext(runnable);
}
private void invokeOnEachAppContext(Runnable runnable) {