8286663: Resolve IDE warnings in WTrayIconPeer and SystemTray
Reviewed-by: prr, serb, honkar
This commit is contained in:
parent
b021d37cec
commit
a9b9831f2a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2022, 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
|
||||
@ -131,15 +131,7 @@ public class SystemTray {
|
||||
private static final TrayIcon[] EMPTY_TRAY_ARRAY = new TrayIcon[0];
|
||||
|
||||
static {
|
||||
AWTAccessor.setSystemTrayAccessor(
|
||||
new AWTAccessor.SystemTrayAccessor() {
|
||||
public void firePropertyChange(SystemTray tray,
|
||||
String propertyName,
|
||||
Object oldValue,
|
||||
Object newValue) {
|
||||
tray.firePropertyChange(propertyName, oldValue, newValue);
|
||||
}
|
||||
});
|
||||
AWTAccessor.setSystemTrayAccessor(SystemTray::firePropertyChange);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,15 +249,16 @@ public class SystemTray {
|
||||
if (trayIcon == null) {
|
||||
throw new NullPointerException("adding null TrayIcon");
|
||||
}
|
||||
TrayIcon[] oldArray = null, newArray = null;
|
||||
Vector<TrayIcon> icons = null;
|
||||
TrayIcon[] oldArray;
|
||||
TrayIcon[] newArray;
|
||||
Vector<TrayIcon> icons;
|
||||
synchronized (this) {
|
||||
oldArray = systemTray.getTrayIcons();
|
||||
@SuppressWarnings("unchecked")
|
||||
Vector<TrayIcon> tmp = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
|
||||
icons = tmp;
|
||||
if (icons == null) {
|
||||
icons = new Vector<TrayIcon>(3);
|
||||
icons = new Vector<>(3);
|
||||
AppContext.getAppContext().put(TrayIcon.class, icons);
|
||||
|
||||
} else if (icons.contains(trayIcon)) {
|
||||
@ -305,7 +298,8 @@ public class SystemTray {
|
||||
if (trayIcon == null) {
|
||||
return;
|
||||
}
|
||||
TrayIcon[] oldArray = null, newArray = null;
|
||||
TrayIcon[] oldArray;
|
||||
TrayIcon[] newArray;
|
||||
synchronized (this) {
|
||||
oldArray = systemTray.getTrayIcons();
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -343,7 +337,7 @@ public class SystemTray {
|
||||
@SuppressWarnings("unchecked")
|
||||
Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
|
||||
if (icons != null) {
|
||||
return icons.toArray(new TrayIcon[icons.size()]);
|
||||
return icons.toArray(EMPTY_TRAY_ARRAY);
|
||||
}
|
||||
return EMPTY_TRAY_ARRAY;
|
||||
}
|
||||
@ -475,7 +469,7 @@ public class SystemTray {
|
||||
private void firePropertyChange(String propertyName,
|
||||
Object oldValue, Object newValue)
|
||||
{
|
||||
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
||||
if (oldValue != null && oldValue.equals(newValue)) {
|
||||
return;
|
||||
}
|
||||
getCurrentChangeSupport().firePropertyChange(propertyName, oldValue, newValue);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2022, 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
|
||||
@ -25,17 +25,20 @@
|
||||
|
||||
package sun.awt.windows;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.Point;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.peer.TrayIconPeer;
|
||||
import java.awt.image.*;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.SunToolkit;
|
||||
@ -49,14 +52,11 @@ final class WTrayIconPeer extends WObjectPeer implements TrayIconPeer {
|
||||
|
||||
IconObserver observer = new IconObserver();
|
||||
boolean firstUpdate = true;
|
||||
Frame popupParent = new Frame("PopupMessageWindow");
|
||||
final Frame popupParent = new Frame("PopupMessageWindow");
|
||||
PopupMenu popup;
|
||||
|
||||
@Override
|
||||
protected void disposeImpl() {
|
||||
if (popupParent != null) {
|
||||
popupParent.dispose();
|
||||
}
|
||||
popupParent.dispose();
|
||||
_dispose();
|
||||
WToolkit.targetDisposedPeer(target, this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user