# HG changeset patch # User ssadetsky # Date 1442386884 -10800 # Node ID 3e91092d2a15b1928aa63bd6898f5f5988f82657 # Parent 6f1200d8999d12f489bbfcd5a4ffdc0bf0e4e2d9 8129838: [macosx] Regression: NPE in java.awt.Choice Reviewed-by: alexsch, azvegint diff -r 6f1200d8999d -r 3e91092d2a15 jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java Tue Sep 15 15:31:34 2015 +0400 +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java Wed Sep 16 10:01:24 2015 +0300 @@ -26,6 +26,8 @@ package com.apple.laf; import java.awt.*; +import java.awt.Insets; +import java.awt.Rectangle; import java.awt.event.*; import javax.swing.*; @@ -195,24 +197,14 @@ final GraphicsDevice[] gs = ge.getScreenDevices(); //System.err.println(" gs.length = " + gs.length); final Rectangle comboBoxBounds = comboBox.getBounds(); - if (gs.length == 1) { - final Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); - - //System.err.println(" scrSize: "+ scrSize); - - // If the combo box is totally off screen, don't show a popup - if ((p.x + comboBoxBounds.width < 0) || (p.y + comboBoxBounds.height < 0) || (p.x > scrSize.width) || (p.y > scrSize.height)) { - return null; - } - Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(comboBox.getGraphicsConfiguration()); - return new Rectangle(0, insets.top, scrSize.width, scrSize.height - insets.top - insets.bottom); - } for (final GraphicsDevice gd : gs) { final GraphicsConfiguration[] gc = gd.getConfigurations(); for (final GraphicsConfiguration element0 : gc) { final Rectangle gcBounds = element0.getBounds(); - if (gcBounds.contains(p)) return gcBounds; + if (gcBounds.contains(p)) { + return getAvailableScreenArea(gcBounds, element0); + } } } @@ -222,13 +214,24 @@ final GraphicsConfiguration[] gc = gd.getConfigurations(); for (final GraphicsConfiguration element0 : gc) { final Rectangle gcBounds = element0.getBounds(); - if (gcBounds.intersects(comboBoxBounds)) return gcBounds; + if (gcBounds.intersects(comboBoxBounds)) { + if (gcBounds.contains(p)) { + return getAvailableScreenArea(gcBounds, element0); + } + } } } return null; } + private Rectangle getAvailableScreenArea(Rectangle bounds, + GraphicsConfiguration gc) { + Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); + return new Rectangle(0, insets.top, bounds.width, + bounds.height - insets.top); + } + @Override protected Rectangle computePopupBounds(int px, int py, int pw, int ph) { final int itemCount = comboBox.getModel().getSize();