Class LocalizableJDialog
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
dev.javai18n.swing.LocalizableJDialog
- All Implemented Interfaces:
dev.javai18n.core.Localizable, ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
A LocalizableJDialog class that supports localizing the title, font, name, accessible name, accessible
description and icon images from an associated ResourceBundle.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class JDialog
JDialog.AccessibleJDialogNested classes/interfaces inherited from class Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityTypeNested classes/interfaces inherited from class Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyNested classes/interfaces inherited from interface dev.javai18n.core.Localizable
dev.javai18n.core.Localizable.LocaleEvent, dev.javai18n.core.Localizable.LocaleEventListener -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe key value used to retrieve the Dialog's localizable properties.Fields inherited from class JDialog
accessibleContext, rootPane, rootPaneCheckingEnabledFields inherited from class Dialog
DEFAULT_MODALITY_TYPEFields inherited from class Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an ownerless LocalizableJDialog with a title from the associated ResourceBundle.protectedLocalizableJDialog(Dialog owner) Constructs a LocalizableJDialog with the specified owner Dialog.protectedLocalizableJDialog(Frame owner) Constructs a LocalizableJDialog with the specified owner Frame.protectedLocalizableJDialog(Window owner) Constructs a LocalizableJDialog with the specified owner Window. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocaleEventListener(dev.javai18n.core.Localizable.LocaleEventListener listener) Registers a listener to receive LocaleEvents when the Locale for ResourceBundles provided by this object is changed (via setBundleLocale).static LocalizableJDialogcreate()Creates and initializes a new ownerless LocalizableJDialog.static LocalizableJDialogCreates and initializes a new LocalizableJDialog with the specified owner Dialog.static LocalizableJDialogCreates and initializes a new LocalizableJDialog with the specified owner Frame.static LocalizableJDialogCreates and initializes a new LocalizableJDialog with the specified owner Window.Locale[]The available Locales for this object.Get the Locale for ResourceBundles provided by this object.Returns the ResourceBundle for the Locale that is currently set (by setBundleLocale) for this object.voidremoveLocaleEventListener(dev.javai18n.core.Localizable.LocaleEventListener listener) Unregisters a listener that is receiving LocaleEvents when the Locale for ResourceBundles provided by this object is changed (via setBundleLocale).voidsetBundleLocale(Locale locale) Sets the bundle locale, fires aLocalizable.LocaleEventto all registered listeners, callsupdateLocaleSpecificValues()to refresh this dialog's locale-specific properties, and callsComponent.setLocale(Locale)to keep the AWT component locale in sync.protected voidUpdates locale-specific properties (title, font, name, accessible name, accessible description, and icon images) by reading aFramePropertyBundlefrom the resource bundle under the key "DialogProperties".Methods inherited from class JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateMethods inherited from class Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBackMethods inherited from class Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFrontMethods inherited from class Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
DIALOG_PROPERTIES_KEY
The key value used to retrieve the Dialog's localizable properties.- See Also:
-
-
Constructor Details
-
LocalizableJDialog
Constructs an ownerless LocalizableJDialog with a title from the associated ResourceBundle.- Throws:
HeadlessException- if GraphicsEnvironment.isHeadless() returns true.
-
LocalizableJDialog
Constructs a LocalizableJDialog with the specified owner Frame.- Parameters:
owner- The Frame from which the dialog is displayed.
-
LocalizableJDialog
Constructs a LocalizableJDialog with the specified owner Dialog.- Parameters:
owner- The Dialog from which the dialog is displayed.
-
LocalizableJDialog
Constructs a LocalizableJDialog with the specified owner Window.- Parameters:
owner- The Window from which the dialog is displayed.
-
-
Method Details
-
create
Creates and initializes a new ownerless LocalizableJDialog.- Returns:
- A LocalizableJDialog with locale-sensitive attributes updated from an associated ResourceBundle.
-
create
Creates and initializes a new LocalizableJDialog with the specified owner Frame.- Parameters:
owner- The Frame from which the dialog is displayed.- Returns:
- A LocalizableJDialog with locale-sensitive attributes updated from an associated ResourceBundle.
-
create
Creates and initializes a new LocalizableJDialog with the specified owner Dialog.- Parameters:
owner- The Dialog from which the dialog is displayed.- Returns:
- A LocalizableJDialog with locale-sensitive attributes updated from an associated ResourceBundle.
-
create
Creates and initializes a new LocalizableJDialog with the specified owner Window.- Parameters:
owner- The Window from which the dialog is displayed.- Returns:
- A LocalizableJDialog with locale-sensitive attributes updated from an associated ResourceBundle.
-
updateLocaleSpecificValues
protected void updateLocaleSpecificValues()Updates locale-specific properties (title, font, name, accessible name, accessible description, and icon images) by reading aFramePropertyBundlefrom the resource bundle under the key "DialogProperties".Called by the
createfactory methods at construction time and bysetBundleLocale(Locale)on each locale change. Subclasses may override this method to apply additional locale-specific values, and should callsuper.updateLocaleSpecificValues()first. AMissingResourceException(e.g. if the key is absent from the bundle) is logged at WARNING level and silently absorbed so that partial initialisation still succeeds. -
getBundleLocale
Get the Locale for ResourceBundles provided by this object.- Specified by:
getBundleLocalein interfacedev.javai18n.core.Localizable- Returns:
- The Locale for ResourceBundles provided by this object.
-
setBundleLocale
Sets the bundle locale, fires aLocalizable.LocaleEventto all registered listeners, callsupdateLocaleSpecificValues()to refresh this dialog's locale-specific properties, and callsComponent.setLocale(Locale)to keep the AWT component locale in sync. Each registeredResourcefullistener component also callssetLocale()on itself when it processes the event on the EDT.Always use
setBundleLocale()to change the application locale. CallingComponent.setLocale(Locale)directly updates the AWT rendering locale but does not reload bundle content or notify any listeners.- Specified by:
setBundleLocalein interfacedev.javai18n.core.Localizable- Parameters:
locale- The new bundle locale.
-
getAvailableLocales
The available Locales for this object.- Specified by:
getAvailableLocalesin interfacedev.javai18n.core.Localizable- Returns:
- An array of the available Locales for this object.
-
getResourceBundle
public ResourceBundle getResourceBundle() throws dev.javai18n.core.NoCallbackRegisteredForModuleExceptionReturns the ResourceBundle for the Locale that is currently set (by setBundleLocale) for this object.- Specified by:
getResourceBundlein interfacedev.javai18n.core.Localizable- Returns:
- The ResourceBundle for the Locale that is currently set (by setBundleLocale) for this object.
- Throws:
dev.javai18n.core.NoCallbackRegisteredForModuleException- if a getBundle callback has not been registered for the module.
-
addLocaleEventListener
public void addLocaleEventListener(dev.javai18n.core.Localizable.LocaleEventListener listener) Registers a listener to receive LocaleEvents when the Locale for ResourceBundles provided by this object is changed (via setBundleLocale).- Specified by:
addLocaleEventListenerin interfacedev.javai18n.core.Localizable- Parameters:
listener- The listener that will receive LocaleEvents.
-
removeLocaleEventListener
public void removeLocaleEventListener(dev.javai18n.core.Localizable.LocaleEventListener listener) Unregisters a listener that is receiving LocaleEvents when the Locale for ResourceBundles provided by this object is changed (via setBundleLocale).- Specified by:
removeLocaleEventListenerin interfacedev.javai18n.core.Localizable- Parameters:
listener- The listener that will be unregistered from receiving LocaleEvents.
-