Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / March 2006

Tip: Looking for answers? Try searching our database.

Translating from one JComponent's coordinates to another's

Thread view: 
Monique Y. Mudama - 28 Mar 2006 01:32 GMT
I *know* I have seen this addressed recently, but I've been flipping
through the javadocs, googling, and search google groups, all without
success.

I have a JPanel that has a JButton.  How can I translate a point in
one to the coordinate space of the other?

The more general problem I am trying to address:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6359129

The idea is, since the clicks don't work if the popup goes beyond the
browser, I can instead move the popup higher so that it fits within
the browser window.  But I'm using

popup.show(button, 5, button.getHeight() - 7);

(showing the popup in the JButton's coordinate space), and I need to
know where it is displaying relative to the JPanel (actually, I guess
it would suffice to know where it is displaying relative to the entire
applet window).

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Roedy Green - 28 Mar 2006 03:14 GMT
On Mon, 27 Mar 2006 17:32:48 -0700, "Monique Y. Mudama"
<spam@bounceswoosh.org> wrote, quoted or indirectly quoted someone who
said :

>I have a JPanel that has a JButton.  How can I translate a point in
>one to the coordinate space of the other?

see http://mindprod.com/jgloss/affinetransform.html
gives you generic way of transforming co-ordinates.

as for you specific problem, see
http://mindprod.com/jgloss/coordinates.html#RELATIVEORIGIN
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Monique Y. Mudama - 28 Mar 2006 04:02 GMT
> On Mon, 27 Mar 2006 17:32:48 -0700, "Monique Y. Mudama"
><spam@bounceswoosh.org> wrote, quoted or indirectly quoted someone
[quoted text clipped - 8 lines]
> as for you specific problem, see
> http://mindprod.com/jgloss/coordinates.html#RELATIVEORIGIN

Thanks!  I knew there was a method "somewhere" out there specific to
Components; I just couldn't find it (apparently because I thought it
would be called transformSomething, not convertSomething).

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Thomas Weidenfeller - 28 Mar 2006 08:05 GMT
> I *know* I have seen this addressed recently, but I've been flipping
> through the javadocs, googling, and search google groups, all without
> success.
>
> I have a JPanel that has a JButton.  How can I translate a point in
> one to the coordinate space of the other?

SwingUtilities.convertPoint()

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.