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