Package jmri.util
Class QuickPromptUtil
- java.lang.Object
- 
- jmri.util.QuickPromptUtil
 
- 
 public class QuickPromptUtil extends java.lang.Object A collection of utilities related to prompting for values
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description (package private) static classQuickPromptUtil.FloatRangePredicate(package private) static classQuickPromptUtil.IntRangePredicate
 - 
Constructor SummaryConstructors Constructor Description QuickPromptUtil()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.function.Predicate<java.lang.Integer>checkIntRange(java.lang.Integer min, java.lang.Integer max, java.lang.String valueLabel)Creates a min/max predicate which will check the bounds.static doublepromptForDouble(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, double oldValue)Utility function to prompt for new double value.static floatpromptForFloat(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, float oldValue)Utility function to prompt for new float value.static intpromptForInt(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, int oldValue)Utility function to prompt for new integer value.static java.lang.IntegerpromptForInteger(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, java.lang.Integer oldValue, java.util.function.Predicate<java.lang.Integer> validator)Utility function to prompt for new integer value.static java.lang.StringpromptForString(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, java.lang.String oldValue)Utility function to prompt for new string value.
 
- 
- 
- 
Constructor Detail- 
QuickPromptUtilpublic QuickPromptUtil() 
 
- 
 - 
Method Detail- 
promptForStringpublic static java.lang.String promptForString(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, java.lang.String oldValue) Utility function to prompt for new string value.- Parameters:
- parentComponent- the parent component
- message- the prompt message
- title- the dialog title
- oldValue- the original string value
- Returns:
- the new string value
 
 - 
promptForIntpublic static int promptForInt(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, int oldValue) Utility function to prompt for new integer value.- Parameters:
- parentComponent- the parent component
- message- the prompt message
- title- the dialog title
- oldValue- the original integer value
- Returns:
- the new integer value
 
 - 
promptForIntegerpublic static java.lang.Integer promptForInteger(java.awt.Component parentComponent, @Nonnull java.lang.String message, @Nonnull java.lang.String title, java.lang.Integer oldValue, @CheckForNull java.util.function.Predicate<java.lang.Integer> validator) Utility function to prompt for new integer value. Allows to constrain values using a Predicate (validator).The validator may throw an IllegalArgumentExceptionwhoseThrowable.getLocalizedMessage()will be displayed. The Predicate may also simply returnfalse, which causes just general message (the value is invalid) to be printed. If the Predicate rejects the input, the OK button is disabled and the user is unable to confirm the dialog.The function returns the original value if the dialog was cancelled or the entered value was empty or invalid. Otherwise, it returns the new value entered by the user. - Parameters:
- parentComponent- the parent component
- message- the prompt message.
- title- title for the dialog
- oldValue- the original value
- validator- the validator instance. May be- null
- Returns:
- the updated value, or the original one.
 
 - 
promptForFloatpublic static float promptForFloat(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, float oldValue) Utility function to prompt for new float value.- Parameters:
- parentComponent- the parent component.
- message- the prompt message
- title- the dialog title
- oldValue- the original float value
- Returns:
- the new float value
 
 - 
promptForDoublepublic static double promptForDouble(java.awt.Component parentComponent, java.lang.String message, java.lang.String title, double oldValue) Utility function to prompt for new double value.- Parameters:
- parentComponent- the parent component
- message- the prompt message
- title- the dialog title
- oldValue- the original double value
- Returns:
- the new double value
 
 - 
checkIntRangepublic static java.util.function.Predicate<java.lang.Integer> checkIntRange(java.lang.Integer min, java.lang.Integer max, java.lang.String valueLabel) Creates a min/max predicate which will check the bounds. Suitable forpromptForInteger(java.awt.Component, java.lang.String, java.lang.String, Integer, java.util.function.Predicate).- Parameters:
- min- minimum value. Use- Integer.MIN_VALUEto disable check.
- max- maximum value, inclusive. Use- Integer.MAX_VALUEto disable check.
- valueLabel- label to be included in the message. Must be already I18Ned.
- Returns:
- predicate instance
 
 
- 
 
-