summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
diff options
context:
space:
mode:
authorEVE <EVE@EVE-PC>2017-03-13 16:42:21 -0400
committerEVE <EVE@EVE-PC>2017-03-13 16:42:21 -0400
commit27bf571d6413c3cc6a5d664b5bddd38d21d7b1cd (patch)
tree847fb52acb091c1c613d37b8477094d5762c6988 /BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
parentaa807a96cae2c47259fb38f710640883060339e9 (diff)
Formatting
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java105
1 files changed, 47 insertions, 58 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
index 0152870..b5f0d6c 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gui/SimpleInternalDialogs.java
@@ -7,7 +7,7 @@ import java.util.function.Predicate;
import javax.swing.JOptionPane;
/**
- * Utility class for getting simple input from the user.
+ * Utility class for getting simple input from the user.
*
* Modified to work with JDesktopPanes
*
@@ -19,26 +19,26 @@ public class SimpleInternalDialogs {
* Get a bounded integer from the user.
*
* @param parent
- * The parent component for the dialogs.
+ * The parent component for the dialogs.
* @param title
- * The title for the dialogs.
+ * The title for the dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @param lowerBound
- * The lower integer bound to accept.
+ * The lower integer bound to accept.
* @param upperBound
- * The upper integer bound to accept.
+ * The upper integer bound to accept.
* @return A int within the specified bounds.
*/
- public static int getBoundedInt(Component parent, String title,
- String prompt, int lowerBound, int upperBound) {
+ public static int getBoundedInt(Component parent, String title, String prompt, int lowerBound, int upperBound) {
return getValue(parent, title, prompt, (strang) -> {
try {
int value = Integer.parseInt(strang);
return (value < upperBound) && (value > lowerBound);
} catch (NumberFormatException nfex) {
- // We don't care about the specifics of the exception, just
+ // We don't care about the specifics of the
+ // exception, just
// that this value isn't good
return false;
}
@@ -49,21 +49,21 @@ public class SimpleInternalDialogs {
* Get a integer from the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A int.
*/
- public static int getInt(Component parent, String title,
- String prompt) {
+ public static int getInt(Component parent, String title, String prompt) {
return getValue(parent, title, prompt, strang -> {
try {
Integer.parseInt(strang);
return true;
} catch (NumberFormatException nfex) {
- // We don't care about this exception, just mark the value
+ // We don't care about this exception, just mark
+ // the value
// as not good
return false;
}
@@ -74,15 +74,14 @@ public class SimpleInternalDialogs {
* Get a string from the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for the dialogs.
+ * The title for the dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A string.
*/
- public static String getString(Component parent, String title,
- String prompt) {
+ public static String getString(Component parent, String title, String prompt) {
if (parent == null) {
throw new NullPointerException("Parent must not be null");
} else if (title == null) {
@@ -91,30 +90,28 @@ public class SimpleInternalDialogs {
throw new NullPointerException("Prompt must not be null");
}
- return JOptionPane.showInternalInputDialog(parent, prompt, title,
- JOptionPane.QUESTION_MESSAGE);
+ return JOptionPane.showInternalInputDialog(parent, prompt, title, JOptionPane.QUESTION_MESSAGE);
}
/**
* Get a value parsable from a string from the user.
*
* @param <E>
- * The type of the value parsed from the string
+ * The type of the value parsed from the string
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @param validator
- * A predicate to determine if a input is valid.
+ * A predicate to determine if a input is valid.
* @param transformer
- * The function to transform the string into a value.
+ * The function to transform the string into a value.
* @return The value parsed from a string.
*/
- public static <E> E getValue(Component parent, String title,
- String prompt, Predicate<String> validator,
+ public static <E> E getValue(Component parent, String title, String prompt, Predicate<String> validator,
Function<String, E> transformer) {
if (validator == null) {
throw new NullPointerException("Validator must not be null");
@@ -137,15 +134,14 @@ public class SimpleInternalDialogs {
* Get a whole number from the user.
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param prompt
- * The prompt to tell the user what to enter.
+ * The prompt to tell the user what to enter.
* @return A whole number.
*/
- public static int getWhole(Component parent, String title,
- String prompt) {
+ public static int getWhole(Component parent, String title, String prompt) {
return getBoundedInt(parent, title, prompt, 0, Integer.MAX_VALUE);
}
@@ -153,15 +149,14 @@ public class SimpleInternalDialogs {
* Ask the user a Yes/No question.
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param question
- * The question to ask the user.
+ * The question to ask the user.
* @return True if the user said yes, false otherwise.
*/
- public static boolean getYesNo(Component parent, String title,
- String question) {
+ public static boolean getYesNo(Component parent, String title, String question) {
if (parent == null) {
throw new NullPointerException("Parent must not be null");
} else if (title == null) {
@@ -170,8 +165,7 @@ public class SimpleInternalDialogs {
throw new NullPointerException("Question must not be null");
}
- int result = JOptionPane.showInternalConfirmDialog(parent,
- question, title, JOptionPane.YES_NO_OPTION);
+ int result = JOptionPane.showInternalConfirmDialog(parent, question, title, JOptionPane.YES_NO_OPTION);
return (result == JOptionPane.YES_OPTION ? true : false);
}
@@ -180,39 +174,35 @@ public class SimpleInternalDialogs {
* Show a error message to the user
*
* @param parent
- * The parent component for dialogs.
+ * The parent component for dialogs.
* @param title
- * The title for dialogs.
+ * The title for dialogs.
* @param message
- * The error to show the user.
+ * The error to show the user.
*/
- public static void showError(Component parent, String title,
- String message) {
+ public static void showError(Component parent, String title, String message) {
if (parent == null) {
throw new NullPointerException("Parent must not be null");
} else if (title == null) {
throw new NullPointerException("Title must not be null");
} else if (message == null) {
- throw new NullPointerException(
- "Error message must not be null");
+ throw new NullPointerException("Error message must not be null");
}
- JOptionPane.showInternalMessageDialog(parent, message, title,
- JOptionPane.ERROR_MESSAGE);
+ JOptionPane.showInternalMessageDialog(parent, message, title, JOptionPane.ERROR_MESSAGE);
}
/**
* Show an informative message to the user
*
* @param parent
- * The parent for this dialog
+ * The parent for this dialog
* @param title
- * Show the title for this dialog
+ * Show the title for this dialog
* @param message
- * Show the message for this dialog
+ * Show the message for this dialog
*/
- public static void showMessage(Component parent, String title,
- String message) {
+ public static void showMessage(Component parent, String title, String message) {
if (parent == null) {
throw new NullPointerException("Parent must not be null");
} else if (title == null) {
@@ -221,7 +211,6 @@ public class SimpleInternalDialogs {
throw new NullPointerException("Message must not be null");
}
- JOptionPane.showInternalMessageDialog(parent, title, message,
- JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showInternalMessageDialog(parent, title, message, JOptionPane.INFORMATION_MESSAGE);
}
}