【问题标题】:How to get screen position of a Swing element?如何获取 Swing 元素的屏幕位置?
【发布时间】:2010-02-03 13:45:51
【问题描述】:

如何获取元素的实际屏幕位置,比如按钮?如果我使用 getBounds 我会得到相对于父容器的位置,而不是屏幕......

【问题讨论】:

    标签: java swing


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      你可以试试这个:

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

      【讨论】:

        猜你喜欢
        • 2019-11-14
        • 1970-01-01
        • 2020-10-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多