开发者

How to get screen position of a Swing element?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜