I think you want topLevelContainer.getVisibleRect(), you just also need to adjust your rectangle coordinate system, e.g. javax.swing.SwingUtilities#convertRectangle.
topLevelContainer.getVisibleRect()
javax.swing.SwingUtilities#convertRectangle