ComponentOrientation (Java SE 15 & JDK 15) (original) (raw)

All Implemented Interfaces:

[Serializable](../../../java.base/java/io/Serializable.html "interface in java.io")


public final class ComponentOrientation extends Object implements Serializable

The ComponentOrientation class encapsulates the language-sensitive orientation that is to be used to order the elements of a component or of text. It is used to reflect the differences in this ordering between Western alphabets, Middle Eastern (such as Hebrew), and Far Eastern (such as Japanese).

Fundamentally, this governs items (such as characters) which are laid out in lines, with the lines then laid out in a block. This also applies to items in a widget: for example, in a check box where the box is positioned relative to the text.

There are four different orientations used in modern languages as in the following table.

LT RT TL TR A B C C B A A D G G D A D E F F E D B E H H E B G H I I H G C F I I F C

(In the header, the two-letter abbreviation represents the item direction in the first letter, and the line direction in the second. For example, LT means "items left-to-right, lines top-to-bottom", TL means "items top-to-bottom, lines left-to-right", and so on.)

The orientations are:

Components whose view and controller code depends on orientation should use the isLeftToRight() andisHorizontal() methods to determine their behavior. They should not include switch-like code that keys off of the constants, such as:

if (orientation == LEFT_TO_RIGHT) { ... } else if (orientation == RIGHT_TO_LEFT) { ... } else { // Oops }

This is unsafe, since more constants may be added in the future and since it is not guaranteed that orientation objects will be unique.

See Also:

Serialized Form

Fields

Modifier and Type Field Description
static ComponentOrientation LEFT_TO_RIGHT Items run left to right and lines flow top to bottom Examples: English, French.
static ComponentOrientation RIGHT_TO_LEFT Items run right to left and lines flow top to bottom Examples: Arabic, Hebrew.
static ComponentOrientation UNKNOWN Indicates that a component's orientation has not been set.

Methods declared in class java.lang.Object

[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)