Class OrientationAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

    public class OrientationAction
    extends javax.swing.AbstractAction
    implements java.beans.PropertyChangeListener
    An action that toggles text orientation.
    Since:
    18221
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Component component  
      private static java.util.List<java.lang.String> DEFAULT_LOCALIZED_KEYS
      Default for LOCALIZED_KEYS
      private static java.util.List<java.lang.String> DEFAULT_RTL_LANGUAGES
      Default for RTL_LANGUAGES
      private javax.swing.ImageIcon iconLTR  
      private javax.swing.ImageIcon iconRTL  
      private static java.util.regex.Pattern LANG_PATTERN  
      static ListProperty LOCALIZED_KEYS
      Keys whose values are localized Regex fractions are allowed.
      protected static java.util.regex.Pattern localizedKeys  
      private static java.lang.String NEW_STATE  
      static ListProperty RTL_LANGUAGES
      Language codes of languages that are right-to-left
      protected static java.util.Set<java.lang.String> RTLLanguages  
      • Fields inherited from class javax.swing.AbstractAction

        changeSupport, enabled
      • Fields inherited from interface javax.swing.Action

        ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
    • Constructor Summary

      Constructors 
      Constructor Description
      OrientationAction​(java.awt.Component component)
      Constructs a new OrientationAction.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)  
      private static java.util.regex.Pattern compileLocalizedKeys()  
      static java.awt.ComponentOrientation getDefaultComponentOrientation()
      Returns the default component orientation by the user's locale
      static java.awt.ComponentOrientation getNamelikeOrientation​(java.lang.String key)
      Returns the text orientation of the value for the given key.
      static javax.swing.KeyStroke getShortcutKey()
      Returns the shortcut key to assign to this action.
      static java.awt.ComponentOrientation getValueOrientation​(java.lang.String key)
      Returns the text orientation of the value for the given key.
      void propertyChange​(java.beans.PropertyChangeEvent evt)  
      void updateState()
      Updates the text and the icon.
      • Methods inherited from class javax.swing.AbstractAction

        addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.Action

        accept
    • Constructor Detail

      • OrientationAction

        public OrientationAction​(java.awt.Component component)
        Constructs a new OrientationAction.
        Parameters:
        component - The component to toggle
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • updateState

        public void updateState()
        Updates the text and the icon.
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • getShortcutKey

        public static javax.swing.KeyStroke getShortcutKey()
        Returns the shortcut key to assign to this action.
        Returns:
        the shortcut key
      • getDefaultComponentOrientation

        public static java.awt.ComponentOrientation getDefaultComponentOrientation()
        Returns the default component orientation by the user's locale
        Returns:
        the default component orientation
      • getValueOrientation

        public static java.awt.ComponentOrientation getValueOrientation​(java.lang.String key)
        Returns the text orientation of the value for the given key. This is intended for Preset Dialog comboboxes. The choices in the dropdown list are typically translated. Ideally the user needs not see the English value. The algorithm is as follows:
        • If the key has an explicit language suffix, return the text orientation for that language.
        • Else return the text orientation of the user's locale.
        You can configure which languages are RTL with the list property: rtl-languages.
        Parameters:
        key - the key
        Returns:
        the text orientation of the value
      • getNamelikeOrientation

        public static java.awt.ComponentOrientation getNamelikeOrientation​(java.lang.String key)
        Returns the text orientation of the value for the given key. This expansion of getValueOrientation(java.lang.String) is intended for Preset Dialog textfields and for the Add Tag and Edit Tag dialog comboboxes. The algorithm is as follows:
        • If the key has an explicit language suffix, return the text orientation for that language.
        • If the key is usually localized, return the text orientation of the user's locale.
        • Else return left to right.
        You can configure which keys are localized with the list property: localized-keys. You can configure which languages are RTL with the list property: rtl-languages.
        Parameters:
        key - the key
        Returns:
        the text orientation of the value