如何获取 Swing 元素的屏幕位置?
如何获取元素的实际屏幕位置,例如按钮?如果我使用getBounds,我会获得相对于父容器的位置,而不是屏幕...
如何获取元素的实际屏幕位置,例如按钮?如果我使用getBounds,我会获得相对于父容器的位置,而不是屏幕...
你可以试试这个:
// Convert a coordinate relative to a component's bounds to screen coordinates
Point pt = new Point(component.getLocation());
SwingUtilities.convertPointToScreen(pt, component);