static Rectangle boundsOnScreen(Component c) { if (c == null) null; if (c.getParent() instanceof JViewport && c.getParent().getParent() instanceof JScrollPane) c = c.getParent().getParent(); try { ret new Rectangle(c.getLocationOnScreen(), c.getSize()); } catch (IllegalComponentStateException e) { null; } }