JDK 6 update 6 does not have SunToolkit.getContainingWindow(c) method.

This commit is contained in:
Denis Fokin
2013-07-26 15:32:02 +04:00
parent f9b37d5138
commit d8ca269f6e
@@ -321,7 +321,7 @@ public class MacMessagesImpl extends MacMessages {
private static Window findDocumentRoot (final Component c) {
if (c == null) return null;
Window w = (c instanceof Window) ? (Window)c : SunToolkit.getContainingWindow(c);
Window w = (c instanceof Window) ? (Window)c : getContainingWindow(c);
synchronized (c.getTreeLock()) {
while (w.getOwner() != null) {
w = w.getOwner();
@@ -330,6 +330,15 @@ public class MacMessagesImpl extends MacMessages {
return w;
}
// This method is not available in jdk 1.6.0_6. Should be changed to the JDK implementation
// as soon as we will have switched on JDK 7.
private static Window getContainingWindow(Component comp) {
while (comp != null && !(comp instanceof Window)) {
comp = comp.getParent();
}
return (Window)comp;
}
private static void startModal(final Window w, ID windowId) {
synchronized (lock) {
windowFromId.put(windowId.longValue(), w);