This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

using getLocationOnScreen()  RSS feed

samuel, liu
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,
I am trying to use Component.getLocationOnScreen()to get the location of any given active/focused Swing Component.
I tested it, it works fine. however, there is one problem: in order to use getLocationOnScreen(), then the active window has to be "extends Component". Well, yes, any JComponent is a Component, but if the programmers didn't mark "extends Component" in their code (in their class definitions), then getLocationOnScreen() can't get the coordinates from that window(or whatever it is). the pain is that it is totally legal to define a Swing class without extends it to a Swing Component.
do you have any suggestions on that problem?
thank you.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!