question: static void zSetPopupLocation ( CustomPopup popup , int defaultX , int defaultY , JComponent picker , JComponent verticalFlipReference , int verticalFlipDistance , int bottomOverlapAllowed ) { Window topWindowOrNull = SwingUtilities . getWindowAncestor ( picker ) ; Rectangle workingArea = InternalUtilities . getScreenWorkingArea ( topWindowOrNull ) ; int popupWidth = popup . getBounds ( ) . width ; int popupHeight = popup . getBounds ( ) . height ; Rectangle popupRectangle = new Rectangle ( defaultX , defaultY , popupWidth , popupHeight ) ; if ( popupRectangle . getMaxY ( ) > ( workingArea . getMaxY ( ) + bottomOverlapAllowed ) ) { popupRectangle . y = verticalFlipReference . getLocationOnScreen ( ) . y - popupHeight - verticalFlipDistance ; } if ( popupRectangle . getMaxX ( ) > ( workingArea . getMaxX ( ) ) ) { popupRectangle . x -= ( popupRectangle . getMaxX ( ) - workingArea . getMaxX ( ) ) ; } if ( popupRectangle . getMaxY ( ) > ( workingArea . getMaxY ( ) + bottomOverlapAllowed ) ) { popupRectangle . y -= ( popupRectangle . getMaxY ( ) - workingArea . getMaxY ( ) ) ; } if ( popupRectangle . x < workingArea . x ) { popupRectangle . x += ( workingArea . x - popupRectangle . x ) ; } if ( popupRectangle . y < workingArea . y ) { popupRectangle . y += ( workingArea . y - popupRectangle . y ) ; } popup . setLocation ( popupRectangle . x , popupRectangle . y ) ; }
target:  zSetPopupLocation, This calculates and sets the appropriate location for the popup windows, for both the DatePicker and the TimePicker.