< prev index next >

src/java.desktop/share/classes/java/awt/Window.java

Print this page




1460      * @since 1.2
1461      */
1462     public Window getOwner() {
1463         return getOwner_NoClientCode();
1464     }
1465     final Window getOwner_NoClientCode() {
1466         return (Window)parent;
1467     }
1468 
1469     /**
1470      * Return an array containing all the windows this
1471      * window currently owns.
1472      *
1473      * @return the array of all the owned windows
1474      * @since 1.2
1475      */
1476     public Window[] getOwnedWindows() {
1477         return getOwnedWindows_NoClientCode();
1478     }
1479     final Window[] getOwnedWindows_NoClientCode() {
1480         Window realCopy[];
1481 
1482         synchronized(ownedWindowList) {
1483             // Recall that ownedWindowList is actually a Vector of
1484             // WeakReferences and calling get() on one of these references
1485             // may return null. Make two arrays-- one the size of the
1486             // Vector (fullCopy with size fullSize), and one the size of
1487             // all non-null get()s (realCopy with size realSize).
1488             int fullSize = ownedWindowList.size();
1489             int realSize = 0;
1490             Window fullCopy[] = new Window[fullSize];
1491 
1492             for (int i = 0; i < fullSize; i++) {
1493                 fullCopy[realSize] = ownedWindowList.elementAt(i).get();
1494 
1495                 if (fullCopy[realSize] != null) {
1496                     realSize++;
1497                 }
1498             }
1499 
1500             if (fullSize != realSize) {
1501                 realCopy = Arrays.copyOf(fullCopy, realSize);
1502             } else {
1503                 realCopy = fullCopy;
1504             }
1505         }
1506 
1507         return realCopy;
1508     }
1509 
1510     boolean isModalBlocked() {


1538             v.addAll(allWindows);
1539             return v;
1540         }
1541     }
1542 
1543     static IdentityArrayList<Window> getAllUnblockedWindows() {
1544         synchronized (allWindows) {
1545             IdentityArrayList<Window> unblocked = new IdentityArrayList<Window>();
1546             for (int i = 0; i < allWindows.size(); i++) {
1547                 Window w = allWindows.get(i);
1548                 if (!w.isModalBlocked()) {
1549                     unblocked.add(w);
1550                 }
1551             }
1552             return unblocked;
1553         }
1554     }
1555 
1556     private static Window[] getWindows(AppContext appContext) {
1557         synchronized (Window.class) {
1558             Window realCopy[];
1559             @SuppressWarnings("unchecked")
1560             Vector<WeakReference<Window>> windowList =
1561                 (Vector<WeakReference<Window>>)appContext.get(Window.class);
1562             if (windowList != null) {
1563                 int fullSize = windowList.size();
1564                 int realSize = 0;
1565                 Window fullCopy[] = new Window[fullSize];
1566                 for (int i = 0; i < fullSize; i++) {
1567                     Window w = windowList.get(i).get();
1568                     if (w != null) {
1569                         fullCopy[realSize++] = w;
1570                     }
1571                 }
1572                 if (fullSize != realSize) {
1573                     realCopy = Arrays.copyOf(fullCopy, realSize);
1574                 } else {
1575                     realCopy = fullCopy;
1576                 }
1577             } else {
1578                 realCopy = new Window[0];
1579             }
1580             return realCopy;
1581         }
1582     }
1583 
1584     /**
1585      * Returns an array of all {@code Window}s, both owned and ownerless,




1460      * @since 1.2
1461      */
1462     public Window getOwner() {
1463         return getOwner_NoClientCode();
1464     }
1465     final Window getOwner_NoClientCode() {
1466         return (Window)parent;
1467     }
1468 
1469     /**
1470      * Return an array containing all the windows this
1471      * window currently owns.
1472      *
1473      * @return the array of all the owned windows
1474      * @since 1.2
1475      */
1476     public Window[] getOwnedWindows() {
1477         return getOwnedWindows_NoClientCode();
1478     }
1479     final Window[] getOwnedWindows_NoClientCode() {
1480         Window[] realCopy;
1481 
1482         synchronized(ownedWindowList) {
1483             // Recall that ownedWindowList is actually a Vector of
1484             // WeakReferences and calling get() on one of these references
1485             // may return null. Make two arrays-- one the size of the
1486             // Vector (fullCopy with size fullSize), and one the size of
1487             // all non-null get()s (realCopy with size realSize).
1488             int fullSize = ownedWindowList.size();
1489             int realSize = 0;
1490             Window[] fullCopy = new Window[fullSize];
1491 
1492             for (int i = 0; i < fullSize; i++) {
1493                 fullCopy[realSize] = ownedWindowList.elementAt(i).get();
1494 
1495                 if (fullCopy[realSize] != null) {
1496                     realSize++;
1497                 }
1498             }
1499 
1500             if (fullSize != realSize) {
1501                 realCopy = Arrays.copyOf(fullCopy, realSize);
1502             } else {
1503                 realCopy = fullCopy;
1504             }
1505         }
1506 
1507         return realCopy;
1508     }
1509 
1510     boolean isModalBlocked() {


1538             v.addAll(allWindows);
1539             return v;
1540         }
1541     }
1542 
1543     static IdentityArrayList<Window> getAllUnblockedWindows() {
1544         synchronized (allWindows) {
1545             IdentityArrayList<Window> unblocked = new IdentityArrayList<Window>();
1546             for (int i = 0; i < allWindows.size(); i++) {
1547                 Window w = allWindows.get(i);
1548                 if (!w.isModalBlocked()) {
1549                     unblocked.add(w);
1550                 }
1551             }
1552             return unblocked;
1553         }
1554     }
1555 
1556     private static Window[] getWindows(AppContext appContext) {
1557         synchronized (Window.class) {
1558             Window[] realCopy;
1559             @SuppressWarnings("unchecked")
1560             Vector<WeakReference<Window>> windowList =
1561                 (Vector<WeakReference<Window>>)appContext.get(Window.class);
1562             if (windowList != null) {
1563                 int fullSize = windowList.size();
1564                 int realSize = 0;
1565                 Window[] fullCopy = new Window[fullSize];
1566                 for (int i = 0; i < fullSize; i++) {
1567                     Window w = windowList.get(i).get();
1568                     if (w != null) {
1569                         fullCopy[realSize++] = w;
1570                     }
1571                 }
1572                 if (fullSize != realSize) {
1573                     realCopy = Arrays.copyOf(fullCopy, realSize);
1574                 } else {
1575                     realCopy = fullCopy;
1576                 }
1577             } else {
1578                 realCopy = new Window[0];
1579             }
1580             return realCopy;
1581         }
1582     }
1583 
1584     /**
1585      * Returns an array of all {@code Window}s, both owned and ownerless,


< prev index next >