Serializable
public final class ComponentOrientation extends Object implements Serializable
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
The orientations are:
isLeftToRight()
and isHorizontal()
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.
Modifier and Type | Field | Description |
---|---|---|
static final ComponentOrientation |
LEFT_TO_RIGHT |
Items run left to right and lines flow top to bottom Examples: English, French. |
static final ComponentOrientation |
RIGHT_TO_LEFT |
Items run right to left and lines flow top to bottom Examples: Arabic, Hebrew. |
static final ComponentOrientation |
UNKNOWN |
Indicates that a component's orientation has not been set. |
Modifier and Type | Method | Description |
---|---|---|
static ComponentOrientation |
getOrientation |
Returns the orientation that is appropriate for the given locale. |
static ComponentOrientation |
getOrientation |
Deprecated. |
boolean |
isHorizontal() |
Are lines horizontal? |
boolean |
isLeftToRight() |
HorizontalLines: Do items run left-to-right? |
public static final ComponentOrientation LEFT_TO_RIGHT
public static final ComponentOrientation RIGHT_TO_LEFT
public static final ComponentOrientation UNKNOWN
public boolean isHorizontal()
true
if this orientation has horizontal linespublic boolean isLeftToRight()
true
if this orientation is left-to-rightpublic static ComponentOrientation getOrientation(Locale locale)
locale
- the specified locale@Deprecated public static ComponentOrientation getOrientation(ResourceBundle bdl)
getOrientation(java.util.Locale)
.bdl
- the bundle to use
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/ComponentOrientation.html
getOrientation(java.util.Locale)
.