Class ComponentOrientation
java.lang.Object
java.awt.ComponentOrientation
- All Implemented Interfaces:
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).
(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.)
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:
- LT - Western Europe (optional for Japanese, Chinese, Korean)
- RT - Middle East (Arabic, Hebrew)
- TR - Japanese, Chinese, Korean
- TL - Mongolian
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.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ComponentOrientationItems run left to right and lines flow top to bottom Examples: English, French.static final ComponentOrientationItems run right to left and lines flow top to bottom Examples: Arabic, Hebrew.static final ComponentOrientationIndicates that a component's orientation has not been set. -
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentOrientationgetOrientation(Locale locale) Returns the orientation that is appropriate for the given locale.static ComponentOrientationDeprecated.booleanAre lines horizontal?booleanHorizontalLines: Do items run left-to-right?Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Field Details
-
LEFT_TO_RIGHT
Items run left to right and lines flow top to bottom Examples: English, French. -
RIGHT_TO_LEFT
Items run right to left and lines flow top to bottom Examples: Arabic, Hebrew. -
UNKNOWN
Indicates that a component's orientation has not been set. To preserve the behavior of existing applications, isLeftToRight will return true for this value.
-
-
Method Details
-
isHorizontal
public boolean isHorizontal()Are lines horizontal? This will return true for horizontal, left-to-right writing systems such as Roman.- Returns:
trueif this orientation has horizontal lines
-
isLeftToRight
public boolean isLeftToRight()HorizontalLines: Do items run left-to-right?
Vertical Lines: Do lines run left-to-right?
This will return true for horizontal, left-to-right writing systems such as Roman.- Returns:
trueif this orientation is left-to-right
-
getOrientation
Returns the orientation that is appropriate for the given locale.- Parameters:
locale- the specified locale- Returns:
- the orientation for the locale
-
getOrientation
Deprecated.As of J2SE 1.4, usegetOrientation(java.util.Locale).Returns the orientation appropriate for the given ResourceBundle's localization. Three approaches are tried, in the following order:- Retrieve a ComponentOrientation object from the ResourceBundle using the string "Orientation" as the key.
- Use the ResourceBundle.getLocale to determine the bundle's locale, then return the orientation for that locale.
- Return the default locale's orientation.
- Parameters:
bdl- the bundle to use- Returns:
- the orientation
-
getOrientation(java.util.Locale).