Skip to main content

getLocation() ?????

1 reply [Last post]
fabryprog
Offline
Joined: 2005-04-13
Points: 0

Hello!

why JButton.getLocation() return Point of the JButton respect to Frame,
but myPanel.getLocation() return Point of the panel respect to father-panel ??????

WHY????????

How do it?

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vtec
Offline
Joined: 2003-09-05
Points: 0

It is hard to believe your worlds because JButton as well as JPanel share same implementation of the location inherited from JComponent. I am working in this area and never experienced this behaviour.

"getLocation()" always works relative to the parent component "getParent()" with the only exception to this being heavy weight window containers - JDialog, JFrame... that always do use screen coordinates.

Please check that you are not mixing Swing components ... JButton, JPanel, JFrame with their AWT counterparts Button, Panel, Frame...

If you still have problem please provide JUnit TestCase, as I still cant believe your words.

Vitek