@@ -43,27 +43,37 @@ public class LocaleComboBox extends ComboBox<Locale> {
4343 private static final String ITEM_FLAG_CLASS_NAME = "fc-locale-combo-box-item-flag" ;
4444
4545 /**
46- * Constant for the default display mode.
46+ * Display mode representing the built-in display modes in LocaleComboBox
4747 * <p>
48- * In this mode, the Locale names are displayed using the default locale's display format.
48+ * These enums can be used in {@link #setDisplayMode(DisplayMode)} to easily switch between the
49+ * built-in display modes.
4950 */
50- public static final int DISPLAY_DEFAULT = 0 ;
51- /**
52- * Constant for the locale-specific display mode.
53- * <p>
54- * In this mode, the Locale names are displayed using the formatting of the specific locale set by
55- * {@link #setDisplayLocale(Locale)}.
56- */
57- public static final int DISPLAY_CUSTOM = 1 ;
58- /**
59- * Constant for the selected display mode.
60- * <p>
61- * In this mode, the Locale names are displayed using the formatting of the currently selected
62- * locale.
63- */
64- public static final int DISPLAY_SELECTED = 2 ;
65-
66- private int displayMode = DISPLAY_DEFAULT ;
51+ public enum DisplayMode {
52+
53+ /**
54+ * Default display mode.
55+ * <p>
56+ * In this mode, the Locale names are displayed using the default locale's display format.
57+ */
58+ DEFAULT ,
59+
60+ /**
61+ * Selected display mode.
62+ * <p>
63+ * In this mode, the Locale names are displayed using the formatting of the currently selected
64+ * locale.
65+ */
66+ SELECTED ,
67+
68+ /**
69+ * Custom display mode.
70+ * <p>
71+ * In this mode, the Locale names are displayed using the formatting of the specific locale set
72+ * by {@link #setDisplayLocale(Locale)}.
73+ */
74+ CUSTOM ;
75+ }
76+ private DisplayMode displayMode = DisplayMode .DEFAULT ;
6777 private Locale customDisplayLocale = Locale .getDefault ();
6878
6979 /**
@@ -80,29 +90,22 @@ public LocaleComboBox() {
8090
8191 /**
8292 * Sets the display mode of the LocaleComboBox.
83- * <p>
84- * The display mode determines how the Locale names are presented in the combo box:
85- * <ul>
86- * <li>{@link #DISPLAY_DEFAULT} - Uses the default locale's display format to show Locale
87- * names.</li>
88- * <li>{@link #DISPLAY_CUSTOM} - Uses the specific locale (set by
89- * {@link #setDisplayLocale(Locale)}) to format the Locale names.</li>
90- * <li>{@link #DISPLAY_SELECTED} - Uses the currently selected locale to format the Locale
91- * names.</li>
92- * </ul>
9393 *
94- * @param displayMode the display mode to use; must be one of {@link #DISPLAY_DEFAULT},
95- * {@link #DISPLAY_CUSTOM}, or {@link #DISPLAY_SELECTED}.
94+ * @param displayMode the display mode to use
95+ *
96+ * @see DisplayMode
9697 */
97- public void setDisplayMode (int displayMode ) {
98+ public void setDisplayMode (DisplayMode displayMode ) {
9899 this .displayMode = displayMode ;
99100 }
100101
101102 /**
102- * Sets the locale used for formatting Locale names when {@link #DISPLAY_LOCALE} mode is active.
103+ * Sets the locale used for formatting Locale names when {@link DisplayMode#CUSTOM} mode is
104+ * active.
103105 * <p>
104- * This locale determines how Locale names are formatted when {@link #DISPLAY_LOCALE} is selected
105- * as the display mode. If the display mode is {@link #DISPLAY_DEFAULT}, this setting is ignored.
106+ * This locale determines how Locale names are formatted when {@link DisplayMode#CUSTOM} is
107+ * selected as the display mode. If the display mode is any other than {@link DisplayMode#CUSTOM},
108+ * this setting is ignored.
106109 *
107110 * @param displayLocale the locale to use for formatting.
108111 */
@@ -129,10 +132,10 @@ private Locale getLocaleForDisplay() {
129132
130133 switch (displayMode ) {
131134
132- case DISPLAY_CUSTOM :
135+ case CUSTOM :
133136 return customDisplayLocale ;
134137
135- case DISPLAY_SELECTED :
138+ case SELECTED :
136139 return this .getValue () == null ? Locale .getDefault () : this .getValue ();
137140
138141 default :
0 commit comments