Class AbstractDialog
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Dialog
javax.swing.JDialog
megamek.client.ui.dialogs.abstractDialogs.AbstractDialog
- All Implemented Interfaces:
WindowListener,ImageObserver,MenuContainer,Serializable,EventListener,Accessible,RootPaneContainer,WindowConstants
- Direct Known Subclasses:
AbstractButtonDialog,AbstractHelpDialog,ASConversionInfoDialog,ASStatsDialog,AutoResolveChanceDialog,AutoResolveProgressDialog,BVDisplayDialog,CostDisplayDialog,EntityReadoutDialog,LiveReadoutDialog,SBFStatsDialog,SBFTargetDialog,TechLevelDisplayDialog,WeightDisplayDialog
This is the base class for dialogs in MegaMek. This class handles setting the UI, managing the X button, managing the
escape key, and saving the dialog preferences.
Inheriting classes must call initialize() in their constructors and override createCenterPane()
This is directly tied to MekHQ's AbstractMHQDialog, and any changes here MUST be verified there.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialogNested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityTypeNested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.TypeNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsFields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabledFields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPEFields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDialog(JDialog dialog, JFrame frame, boolean modal, ResourceBundle resources, String name, String title) This allows Swing to create the dialog with another dialog as the parent.protectedAbstractDialog(JFrame frame, boolean modal, String name, String title) This creates an AbstractDialog using the default resource bundle.protectedAbstractDialog(JFrame frame, boolean modal, ResourceBundle resources, String name, String title) This creates an AbstractDialog using the specified resource bundle.protectedAbstractDialog(JFrame frame, String name, String title) This creates a non-modal AbstractDialog using the default resource bundle. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAction performed when the Cancel button is clicked, the dialog is closed by the X button, or the escape key is pressedprotected voidNote: Cancelling a dialog should always allow one to close the dialog.protected abstract ContainerThis is used to create the dialog's center paneprotected voidThis MUST be called at the end of initialization to finalize it.protected voidfit()Re-sizes the dialog to a maximum width and height of 80% of the screen size when necessary.protected voidRe-sizes the dialog to a maximum width and height of 80% of the screen size when necessary.getFrame()protected voidInitializes the dialog's UI and preferences.protected voidsetCustomPreferences(PreferencesNode preferences) Adds custom preferences to the child dialog.voidprotected voidThis is used to set preferences based on the preference node for this class.protected voidsetPreferences(PreferencesNode preferences) This sets the base preferences for this class, and calls the custom preferences methodvoidvoidwindowClosed(WindowEvent evt) voidwindowClosing(WindowEvent evt) Note: Closing the dialog should always allow one to close the dialog.voidvoidvoidvoidwindowOpened(WindowEvent evt) Methods inherited from class javax.swing.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 java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBackMethods inherited from class java.awt.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 java.awt.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 java.awt.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
-
CLOSE_ACTION
- See Also:
-
resources
-
-
Constructor Details
-
AbstractDialog
This creates a non-modal AbstractDialog using the default resource bundle. This is the normal constructor to use for an AbstractDialog. -
AbstractDialog
This creates an AbstractDialog using the default resource bundle. It allows one to create modal dialogs. -
AbstractDialog
protected AbstractDialog(JFrame frame, boolean modal, ResourceBundle resources, String name, String title) This creates an AbstractDialog using the specified resource bundle. This is not recommended by default.- Parameters:
frame- the dialog's parent framemodal- if this dialog is modalresources- the resource bundle for this dialogname- the dialog's nametitle- the dialog's title resource key. This is required for accessibility reasons, and the method will error out if it isn't valid.
-
AbstractDialog
protected AbstractDialog(JDialog dialog, JFrame frame, boolean modal, ResourceBundle resources, String name, String title) This allows Swing to create the dialog with another dialog as the parent. Which dialog swing renders on top is somewhat undefined, depending on the window manager. This can cause problems in the case of modal dialogs that show up behind other dialogs, and you cannot get to them.- Parameters:
dialog- Owning dialog, for dialogs on dialogsframe- Owning framemodal- if this dialog is modalresources- the resource bundle for this dialogname- the dialog's nametitle- the dialog's title resource key. This is required for accessibility reasons, and the method will error out if it isn't valid.
-
-
Method Details
-
getFrame
-
setFrame
-
initialize
protected void initialize()Initializes the dialog's UI and preferences. Needs to be called by child classes for initial setup.Anything that overrides this method MUST end by calling
finalizeInitialization() -
createCenterPane
This is used to create the dialog's center pane- Returns:
- the center pane of the dialog
-
finalizeInitialization
This MUST be called at the end of initialization to finalize it. This is the key method for this being the abstract basis for all other dialogs.- Throws:
Exception- if there's an issue finishing initialization. Normally this means there's an issue setting the preferences, which normally means that a component has had its name value set.
-
fit
protected void fit()Re-sizes the dialog to a maximum width and height of 80% of the screen size when necessary. If the dialog goes off-screen, center it -
fitAndCenter
protected void fitAndCenter()Re-sizes the dialog to a maximum width and height of 80% of the screen size when necessary. It then centers the dialog on the screen. -
setPreferences
This is used to set preferences based on the preference node for this class. It is overridden for MekHQ usage.- Throws:
Exception- if there's an issue initializing the preferences. Normally this means a component has not had its name value set.
-
setPreferences
This sets the base preferences for this class, and calls the custom preferences method- Throws:
Exception- if there's an issue initializing the preferences. Normally this means a component has not had its name value set.
-
setCustomPreferences
Adds custom preferences to the child dialog.By default, this dialog will track preferences related to the size and position of the dialog. Other preferences can be added by overriding this method.
- Parameters:
preferences- the preference node for this dialog- Throws:
Exception- if there's an issue initializing the preferences. Normally this means a component has not had its name value set.
-
cancelActionPerformed
Note: Cancelling a dialog should always allow one to close the dialog. -
cancelAction
protected void cancelAction()Action performed when the Cancel button is clicked, the dialog is closed by the X button, or the escape key is pressed -
windowClosing
Note: Closing the dialog should always allow one to close the dialog.- Specified by:
windowClosingin interfaceWindowListener
-
windowOpened
- Specified by:
windowOpenedin interfaceWindowListener
-
windowClosed
- Specified by:
windowClosedin interfaceWindowListener
-
windowIconified
- Specified by:
windowIconifiedin interfaceWindowListener
-
windowDeiconified
- Specified by:
windowDeiconifiedin interfaceWindowListener
-
windowActivated
- Specified by:
windowActivatedin interfaceWindowListener
-
windowDeactivated
- Specified by:
windowDeactivatedin interfaceWindowListener
-