diff --git a/jdk/src/share/classes/javax/swing/JPopupMenu.java b/jdk/src/share/classes/javax/swing/JPopupMenu.java index 286d1bb2a0f..01763f666a9 100644 --- a/jdk/src/share/classes/javax/swing/JPopupMenu.java +++ b/jdk/src/share/classes/javax/swing/JPopupMenu.java @@ -359,17 +359,20 @@ public class JPopupMenu extends JComponent implements Accessible,MenuElement { int scrBottomY = scrBounds.y + scrHeight; // Ensure that popup menu fits the screen - if (popupRightX > (long)scrRightX) { + if (popupRightX > (long) scrRightX) { popupLocation.x = scrRightX - popupSize.width; - if( popupLocation.x < scrBounds.x ) { - popupLocation.x = scrBounds.x ; - } } - if (popupBottomY > (long)scrBottomY) { + + if (popupBottomY > (long) scrBottomY) { popupLocation.y = scrBottomY - popupSize.height; - if( popupLocation.y < scrBounds.y ) { - popupLocation.y = scrBounds.y; - } + } + + if (popupLocation.x < scrBounds.x) { + popupLocation.x = scrBounds.x; + } + + if (popupLocation.y < scrBounds.y) { + popupLocation.y = scrBounds.y; } return popupLocation;