25
요소의 실제 화면 위치를 얻으려면 어떻게해야합니까? 예를 들어 Button? 나는 도로 getBounds를 사용하는 경우 나는Swing 요소의 화면 위치를 얻는 방법은 무엇입니까?
이요소의 실제 화면 위치를 얻으려면 어떻게해야합니까? 예를 들어 Button? 나는 도로 getBounds를 사용하는 경우 나는Swing 요소의 화면 위치를 얻는 방법은 무엇입니까?
이당신이 Component.getLocationOnScreen()
를 시도?
당신이 시도 할 수 있습니다 ... 부모 컨테이너가 아닌 화면에 위치를 얻을 :
// Convert a coordinate relative to a component's bounds to screen coordinates
Point pt = new Point(component.getLocation());
SwingUtilities.convertPointToScreen(pt, component);