Package nz.ac.waikato.cms.gui.core
Class GUIHelper
java.lang.Object
nz.ac.waikato.cms.gui.core.GUIHelper
Helper class for GUI related stuff.
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charthe mnemonic character indicator. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseParent(Container cont) Closes the parent dialog/frame of this container.static ImageIconReturns an ImageIcon from the given name.static StringgetImageFilename(String name) Adds the path of the images directory to the name of the image.static chargetMnemonic(String caption) Returns the mnemonic for this caption, preceded by an underscore "_".static ObjectTries to determine the parent this panel is part of.static ComponentgetParentComponent(Component comp) Tries to determine the component this panel is part of in this order: 1.static DialoggetParentDialog(Component comp) Tries to determine the dialog this component is part of.static DialoggetParentDialog(Container cont) Tries to determine the dialog this container is part of.static FramegetParentFrame(Component comp) Tries to determine the frame the component is part of.static FramegetParentFrame(Container cont) Tries to determine the frame the container is part of.static JInternalFrameTries to determine the internal frame this component is part of.static JInternalFrameTries to determine the internal frame this container is part of.static booleanhasMnemonic(String caption) Checks the caption whether an underscore "_" is present to indicate that the following character is to act as mnemonic.static voidshowErrorMessage(Component parent, String msg) Displays an error message with the default title "Error".static voidshowErrorMessage(Component parent, String msg, String title) Displays an error message.static voidshowErrorMessage(Component parent, String msg, Throwable t) Displays an error message with the default title "Error".static StringstripMnemonic(String caption) Removes the mnemonic indicator in this caption.
-
Field Details
-
MNEMONIC_INDICATOR
public static final char MNEMONIC_INDICATORthe mnemonic character indicator.- See Also:
-
-
Constructor Details
-
GUIHelper
public GUIHelper()
-
-
Method Details
-
getImageFilename
Adds the path of the images directory to the name of the image.- Parameters:
name- the name of the image to add the path to- Returns:
- the full path of the image
-
getIcon
Returns an ImageIcon from the given name.- Parameters:
name- the filename without path- Returns:
- the ImageIcon or null if not available
-
getParent
Tries to determine the parent this panel is part of.- Parameters:
cont- the container to get the parent forparentClass- the class of the parent to obtain- Returns:
- the parent if one exists or null if not
-
getParentFrame
Tries to determine the frame the container is part of.- Parameters:
cont- the container to get the frame for- Returns:
- the parent frame if one exists or null if not
-
getParentFrame
Tries to determine the frame the component is part of.- Parameters:
comp- the component to get the frame for- Returns:
- the parent frame if one exists or null if not
-
getParentDialog
Tries to determine the dialog this container is part of.- Parameters:
cont- the container to get the dialog for- Returns:
- the parent dialog if one exists or null if not
-
getParentDialog
Tries to determine the dialog this component is part of.- Parameters:
comp- the component to get the dialog for- Returns:
- the parent dialog if one exists or null if not
-
getParentInternalFrame
Tries to determine the internal frame this container is part of.- Parameters:
cont- the container to start with- Returns:
- the parent internal frame if one exists or null if not
-
getParentInternalFrame
Tries to determine the internal frame this component is part of.- Parameters:
comp- the component to start with- Returns:
- the parent internal frame if one exists or null if not
-
getParentComponent
Tries to determine the component this panel is part of in this order: 1. dialog, 2. child, 3. frame.- Parameters:
comp- the component to get the parent component for, must be a container actually- Returns:
- the parent component if one exists or null if not
- See Also:
-
closeParent
Closes the parent dialog/frame of this container.- Parameters:
cont- the container to close the parent for
-
hasMnemonic
Checks the caption whether an underscore "_" is present to indicate that the following character is to act as mnemonic.- Parameters:
caption- the caption to analyze- Returns:
- true if an underscore is present
- See Also:
-
getMnemonic
Returns the mnemonic for this caption, preceded by an underscore "_".- Parameters:
caption- the caption to extract- Returns:
- the extracted mnemonic, \0 if none available
- See Also:
-
stripMnemonic
Removes the mnemonic indicator in this caption.- Parameters:
caption- the caption to process- Returns:
- the processed caption
- See Also:
-
showErrorMessage
Displays an error message with the default title "Error".- Parameters:
parent- the parent, to make the dialog modal; can be nullmsg- the error message to displayt- the exception to append to the message
-
showErrorMessage
Displays an error message with the default title "Error".- Parameters:
parent- the parent, to make the dialog modal; can be nullmsg- the error message to display
-
showErrorMessage
Displays an error message.- Parameters:
parent- the parent, to make the dialog modal; can be nullmsg- the error message to displaytitle- the title of the error message
-