This commit is contained in:
prrace 2026-01-26 14:59:35 -08:00
parent 12570be64a
commit 08f95226d2

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2026, 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
@ -54,7 +54,6 @@ import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
import sun.awt.AWTAccessor;
import sun.awt.AppContext;
/**
* An implementation of the Icon interface that paints Icons
@ -136,8 +135,6 @@ public class ImageIcon implements Icon, Serializable, Accessible {
*/
private static int mediaTrackerID;
private static final Object TRACKER_KEY = new StringBuilder("TRACKER_KEY");
int width = -1;
int height = -1;
@ -346,24 +343,12 @@ public class ImageIcon implements Icon, Serializable, Accessible {
}
}
private static final MediaTracker MEDIA_TRACKER = new MediaTracker(new Component() {});
/**
* Returns the MediaTracker for the current AppContext, creating a new
* MediaTracker if necessary.
* Returns the shared MediaTracker.
*/
private MediaTracker getTracker() {
Object trackerObj;
AppContext ac = AppContext.getAppContext();
// Opt: Only synchronize if trackerObj comes back null?
// If null, synchronize, re-check for null, and put new tracker
synchronized(ac) {
trackerObj = ac.get(TRACKER_KEY);
if (trackerObj == null) {
Component comp = new Component() {};
trackerObj = new MediaTracker(comp);
ac.put(TRACKER_KEY, trackerObj);
}
}
return (MediaTracker) trackerObj;
return MEDIA_TRACKER;
}
/**