[英]Map physical screen position to an array of GraphicsDevice with Swing
[英]How to get screen position of a Swing element?
如何獲取元素的實際屏幕位置,比如說按鈕? 如果我使用getBounds,我得到相對於父容器的位置,而不是屏幕......
你可以試試這個:
// Convert a coordinate relative to a component's bounds to screen coordinates
Point pt = new Point(component.getLocation());
SwingUtilities.convertPointToScreen(pt, component);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.