Search code examples
javaswingborder-layoutcode-documentation

Proper static usage with BorderLayout


Documentation I have read for BorderLayout claim that is is best to use PAGE_END, PAGE_START, LINE_START, LINE_END, and CENTER. (https://docs.oracle.com/javase/tutorial/uiswing/layout/border.html)

However, I have also found documentation that uses NORTH, EAST, SOUTH, WEST, and CENTER. (https://docs.oracle.com/javase/7/docs/api/java/awt/BorderLayout.html) since the first set map directly to this one.

Which set of constants should be used when using BorderLayout, and if it doesn't matter then which set would be most commonly used?


Solution

  • They are not equivalent

    The documentation for LINE_END for example states:

    For Western, left-to-right and top-to-bottom orientations, this is equivalent to EAST

    That is, in other orientations (e.g., Hebrew) it's not equivalent to EAST.