簡體   English   中英

如何獲取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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM