Package edu.cnu.mdi.dialog
Class DialogUtils
java.lang.Object
edu.cnu.mdi.dialog.DialogUtils
Utility methods and response constants used by MDI dialogs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDialog "Reason" constantstatic final intDialog "Reason" constantstatic final intDialog "Reason" constantstatic final intDialog "Reason" constantstatic final intDialog "Reason" constantstatic final intDialog "Reason" constant -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcenterDialog(JDialog dialog) Center a dialogstatic JPanelpaddedPanel(int hpad, int vpad, Component component) Create a nice padded panel.static StringConvenience routine for padding a string using the default font.static voidrequestDetailsView(JFileChooser chooser) Attempts to place a file chooser in details view.static voidupperRightComponent(Component component, int dh, int dv) Place a component in the upper rightstatic intyesNoDialog(String prompt, String... options) Create a dialog with a prompt and a set of options
-
Field Details
-
OK_RESPONSE
public static final int OK_RESPONSEDialog "Reason" constant- See Also:
-
CANCEL_RESPONSE
public static final int CANCEL_RESPONSEDialog "Reason" constant- See Also:
-
APPLY_RESPONSE
public static final int APPLY_RESPONSEDialog "Reason" constant- See Also:
-
DONE_RESPONSE
public static final int DONE_RESPONSEDialog "Reason" constant- See Also:
-
YES_RESPONSE
public static final int YES_RESPONSEDialog "Reason" constant- See Also:
-
NO_RESPONSE
public static final int NO_RESPONSEDialog "Reason" constant- See Also:
-
-
Method Details
-
centerDialog
Center a dialog- Parameters:
dialog- the dialog to center
-
upperRightComponent
Place a component in the upper right- Parameters:
component- The Component to center.
-
padString
Convenience routine for padding a string using the default font.Pads
inpwith trailing spaces so that, when rendered inc's font, its pixel width approximateststr's pixel width as closely as possible (adding one space at a time until the width gap stops shrinking).- Parameters:
c- the component supplying the font metrics used to measure pixel widthsinp- the string to be padded;nullis treated as emptytstr- the target string-- try to return a string that renders at about the same pixel width- Returns:
inp(or the empty string) with zero or more trailing spaces appended
-
paddedPanel
Create a nice padded panel.- Parameters:
hpad- the pixel pad on the left and rightvpad- the pixel pad on the top and bottomcomponent- the main component placed in the center.- Returns:
- the padded panel
-
yesNoDialog
Create a dialog with a prompt and a set of options- Parameters:
prompt- the message displayed to the useroptions- the available response labels- Returns:
- the selected option index, or
-1if the dialog was closed
-
requestDetailsView
Attempts to place a file chooser in details view.This relies on a look-and-feel action name and therefore is not guaranteed to work with every Swing look and feel.
- Parameters:
chooser- the file chooser
-