开发者

How to get screen position of a Swing element?

开发者 https://www.devze.com 2022-12-19 14:30 出处:网络
how do I get the开发者_如何学Python actual screen position of an element, say a Button? If I use getBounds I get the position relative to the parent container, not the screen... Have you tried Compone

how do I get the开发者_如何学Python actual screen position of an element, say a Button? If I use getBounds I get the position relative to the parent container, not the screen...


Have you tried Component.getLocationOnScreen()?


You can try this:

// Convert a coordinate relative to a component's bounds to screen coordinates 
Point pt = new Point(component.getLocation()); 
SwingUtilities.convertPointToScreen(pt, component); 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号