Package org.svetovid.dialogs
Class Dialogs
java.lang.Object
org.svetovid.dialogs.Dialogs
This is helper class which contains static methods for showing various types
of dialog boxes containing messages, information, questions, etc.
- Version:
- 1.5
- Author:
- Ivan Pribela
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaskConfirmation(Component component, String text) Displays confirmation message box containing desired message, and asking from the user to answer {code Yes} orNo.static BooleanaskConfirmationWithCancel(Component component, String text) Displays confirmation message box containing desired message, and asking from the user to answer Yes, No or Cancel.static LoginDataDisplays login dialog box containing desired message, and asking for user name and password.static LoginDataDisplays login dialog box containing desired message, and asking for user name and password.static char[]askPassword(Component component, String text) Displays password dialog box containing desired message, and asking from the user to enter password.static StringaskQuestion(Component component, String text) Displays question message box containing desired question, and asking the user to enter the answer.static ObjectaskQuestion(Component component, String text, Object[] options, Object defaultOption) Displays question message box containing desired question, and asking the user to choose one of the provided options.static StringaskQuestion(Component component, String text, String answer) Displays question message box containing desired question, and asking the user to enter the answer.static AutoCloseDialogFactorygetFactory(Locale locale) static AutoCloseDialogFactorygetFactory(Locale locale, Clipboard clipboard) static AutoCloseDialogFactorygetFactory(Locale locale, Clipboard clipboard, int timeout) static voidsetClipboard(Clipboard newValue) Sets clipboard which will be used by displayed messages.static voidSets locale which will be used to display messages.voidsetNewStackTraceStyle(boolean newValue) Sets the stack trace style which will be used by displayed messages.static voidsetTimeout(int newValue) Sets default time before automatically closing dialogs.static booleanshowDialog(Component component, Component content, String title, Icon icon) Displays a dialog with the given icon and title containing the supplied component.static <T> TshowDialog(Component component, DialogContent<T> content, String title, Icon icon) Displays a dialog with the given icon and title containing the supplied content.static voidDisplays error message box containing desired message.static voidDisplays error message box containing desired message and optionally stack-trace of the supplied exception.static voidshowException(Component component, Throwable th) Displays error message box containing stack-trace of the supplied exception.static voidshowInformation(Component component, String text) Displays informational message box containing desired message.static voidshowMessage(Component component, String text) Displays message box containing desired message.static voidshowWarning(Component component, String text) Displays warning message box containing desired message.
-
Constructor Details
-
Dialogs
public Dialogs()
-
-
Method Details
-
setLocale
Sets locale which will be used to display messages.- Parameters:
newValue- locale which will be used to display messages.
-
setClipboard
Sets clipboard which will be used by displayed messages.- Parameters:
newValue- clipboard which will be used by displayed messages.
-
setNewStackTraceStyle
public void setNewStackTraceStyle(boolean newValue) Sets the stack trace style which will be used by displayed messages.- Parameters:
newValue- stack trace style which will be used by displayed messages.
-
setTimeout
public static void setTimeout(int newValue) Sets default time before automatically closing dialogs.- Parameters:
newValue- the auto close timeout; zero means don't auto close dialogs.
-
showMessage
Displays message box containing desired message.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.
-
showInformation
Displays informational message box containing desired message.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.
-
showWarning
Displays warning message box containing desired message.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.
-
showError
Displays error message box containing desired message.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.
-
showError
Displays error message box containing desired message and optionally stack-trace of the supplied exception.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.th- exception which is used to build up the stack-trace information.
-
showException
Displays error message box containing stack-trace of the supplied exception.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.th- exception which is used to build up the stack-trace information.
-
askConfirmation
Displays confirmation message box containing desired message, and asking from the user to answer {code Yes} orNo.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.- Returns:
trueif user answeredyes;falseotherwise.
-
askConfirmationWithCancel
Displays confirmation message box containing desired message, and asking from the user to answer Yes, No or Cancel.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.- Returns:
Trueif user answeredyes;Falseif user answeredno; andnullotherwise.
-
askQuestion
Displays question message box containing desired question, and asking the user to enter the answer.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.- Returns:
Stringobject containing text that user entered;nullif user has chosen not to answer.
-
askQuestion
Displays question message box containing desired question, and asking the user to enter the answer.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.answer- the initial answer for user to modify.- Returns:
Stringobject containing text that user entered;nullif user has chosen not to answer.
-
askQuestion
public static Object askQuestion(Component component, String text, Object[] options, Object defaultOption) Displays question message box containing desired question, and asking the user to choose one of the provided options.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the message box.options- list of available options for the user to choose from.defaultOption- initial option that is to be selected.- Returns:
- one of the options provided or
nullif user has chosen not to answer.
-
askPassword
Displays password dialog box containing desired message, and asking from the user to enter password.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the dialog box.- Returns:
- password entered by the user as an array of
char;nullif user has chosen not to enter the password.
-
askLogin
Displays login dialog box containing desired message, and asking for user name and password.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the dialog box.- Returns:
- user data (user name and password) stored in
LoginDataobject;nullif user has chosen not to enter login data.
-
askLogin
Displays login dialog box containing desired message, and asking for user name and password.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.text- text which will be displayed in the dialog box.username- default user name.- Returns:
- user data (user name and password) stored in
LoginDataobject;nullif user has chosen not to enter login information.
-
showDialog
Displays a dialog with the given icon and title containing the supplied component.- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.content- the component to display on the dialogtitle- title of the dialogicon- icon to display on the dialog- Returns:
trueif user answeredok;falseotherwise.
-
showDialog
public static <T> T showDialog(Component component, DialogContent<T> content, String title, Icon icon) Displays a dialog with the given icon and title containing the supplied content.- Type Parameters:
T- type of dialog content- Parameters:
component- determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.content- the component to display on the dialogtitle- title of the dialogicon- icon to display on the dialog- Returns:
- The object retrieved from the content component if user answered
ok;nullotherwise.
-
getFactory
-
getFactory
-
getFactory
-