Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Clarification of positioning best practices

868609Jun 26 2011 — edited Jul 4 2011
Hi guys

I have been looking over the different ways to position objects and seen a variety of techniques used..

I would really like to start a conversation to clarify how to do somethings:

To give a bit of background on my situation. I am using a BorderLayout and want to be able to allow users to drag an imageView from the right pane to the center pane. I want to know what is the best way to use positioning functions.


A lot of examples use setLayoutX(x) to position - but in the API doco it indicates that
"Defines the x coordinate of the translation that is added to this @@code Node's transform for the purpose of layout."


So my understanding is that this is how to set the layout offset on the X axis. But that this should not be used for actually positioning nodes?

So I was thinking that perhaps setTranslate(x) was the right thing to use for the specific positioning of the Node within the center region.

I have been looking at say this example by Narayan which uses things a bit differently - is this correct?

http://blog.ngopal.com.np/?p=791

I was looking at the API doco and it indicates that you should use 'relocate' instead of setLayout

"Sets the node's layoutX and layoutY translation properties in order to relocate this node to the x,y location in the parent.
This method does not alter translateX or translateY, which if also set will be added to layoutX and layoutY, adjusting the final location by corresponding amounts."

Can I get someone to comment on this please?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 1 2011
Added on Jun 26 2011
3 comments
628 views