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