jdk/src/macosx/classes/sun/awt/CGraphicsEnvironment.java

Print this page




 150     private void initDevices() {
 151         synchronized (this) {
 152             final Map<Integer, CGraphicsDevice> old = new HashMap<>(devices);
 153             devices.clear();
 154 
 155             int mainID = getMainDisplayID();
 156 
 157             // initialization of the graphics device may change
 158             // list of displays on hybrid systems via an activation
 159             // of discrete video.
 160             // So, we initialize the main display first, and then
 161             // retrieve actual list of displays.
 162             if (!old.containsKey(mainID)) {
 163                 old.put(mainID, new CGraphicsDevice(mainID));
 164             }
 165 
 166             for (final int id : getDisplayIDs()) {
 167                 devices.put(id, old.containsKey(id) ? old.get(id)
 168                                                     : new CGraphicsDevice(id));
 169             }



 170         }
 171         displayChanged();
 172     }
 173 
 174     @Override
 175     public synchronized GraphicsDevice getDefaultScreenDevice() throws HeadlessException {
 176         final int mainDisplayID = getMainDisplayID();
 177         CGraphicsDevice d = devices.get(mainDisplayID);
 178         if (d == null) {
 179             // we do not expect that this may happen, the only response
 180             // is to re-initialize the list of devices
 181             initDevices();
 182 
 183             d = devices.get(mainDisplayID);
 184         }
 185         return d;
 186     }
 187 
 188     @Override
 189     public synchronized GraphicsDevice[] getScreenDevices() throws HeadlessException {




 150     private void initDevices() {
 151         synchronized (this) {
 152             final Map<Integer, CGraphicsDevice> old = new HashMap<>(devices);
 153             devices.clear();
 154 
 155             int mainID = getMainDisplayID();
 156 
 157             // initialization of the graphics device may change
 158             // list of displays on hybrid systems via an activation
 159             // of discrete video.
 160             // So, we initialize the main display first, and then
 161             // retrieve actual list of displays.
 162             if (!old.containsKey(mainID)) {
 163                 old.put(mainID, new CGraphicsDevice(mainID));
 164             }
 165 
 166             for (final int id : getDisplayIDs()) {
 167                 devices.put(id, old.containsKey(id) ? old.get(id)
 168                                                     : new CGraphicsDevice(id));
 169             }
 170             if (devices.isEmpty()) {
 171                 throw new AWTError("no screen devices");
 172             }
 173         }
 174         displayChanged();
 175     }
 176 
 177     @Override
 178     public synchronized GraphicsDevice getDefaultScreenDevice() throws HeadlessException {
 179         final int mainDisplayID = getMainDisplayID();
 180         CGraphicsDevice d = devices.get(mainDisplayID);
 181         if (d == null) {
 182             // we do not expect that this may happen, the only response
 183             // is to re-initialize the list of devices
 184             initDevices();
 185 
 186             d = devices.get(mainDisplayID);
 187         }
 188         return d;
 189     }
 190 
 191     @Override
 192     public synchronized GraphicsDevice[] getScreenDevices() throws HeadlessException {