Class InfoDialogHelper
AbstractViewInfo content in a lightweight,
non-modal, non-stealing info dialog.
Deduplication
Only one info dialog per owner window is kept open at a time.
Calling showInfoDialog(java.awt.Component, edu.cnu.mdi.view.AbstractViewInfo) while a dialog is already open for the same
owner brings the existing dialog to the front and replaces its content with
the new AbstractViewInfo. This prevents multiple identical dialogs
accumulating when the user clicks an info button repeatedly, and allows the
same dialog shell to serve different views as the user navigates.
Ownership and memory management
The owner-to-dialog mapping uses a WeakHashMap keyed on the
Window ancestor of the parent component. When an owner
window is garbage-collected its entry is removed automatically, so the map
never prevents window cleanup. A WindowAdapter on each dialog also
removes its entry when the dialog is explicitly closed, so that the next
call creates a fresh dialog rather than reusing a disposed one.
Caller contract
- Must be called on the Swing EDT.
- Callers that hold a reference to the returned
JDialogand wish to close it programmatically should callWindow.dispose()on it; the helper will detect the disposal and remove the entry from its tracking map so that a fresh dialog can be shown later.
-
Method Summary
Modifier and TypeMethodDescriptionstatic JDialogshowInfoDialog(Component parent, AbstractViewInfo info) Show an info dialog for the givenAbstractViewInfo, reusing any existing dialog that belongs to the same owner window.
-
Method Details
-
showInfoDialog
Show an info dialog for the givenAbstractViewInfo, reusing any existing dialog that belongs to the same owner window.If a dialog for this owner is already open and has not been disposed, it is brought to the front and its HTML content is updated to
info. The scroll position is reset to the top. This allows the same dialog to be reused when the user opens info for different views without closing the panel in between.When no reusable dialog exists for this owner, a new one is created. It is configured as:
- Modeless (
Dialog.ModalityType.MODELESS) — does not block the parent window. - Non-focus-stealing (
autoRequestFocus = false,focusableWindowState = false) — clicking the info button does not shift keyboard focus away from the main window. Window.Type.UTILITY— suppresses the taskbar entry on platforms that honour this type.
Must be called on the Swing EDT.
- Parameters:
parent- the component relative to which the dialog is positioned; must not benullinfo- the view-info object whose HTML to display; must not benull- Returns:
- the shown (possibly pre-existing) dialog; never
null
- Modeless (
-