Package docking.widgets.dialogs
Class AbstractNumberInputDialog
java.lang.Object
docking.DialogComponentProvider
docking.widgets.dialogs.AbstractNumberInputDialog
- All Implemented Interfaces:
ActionContextProvider,StatusListener,TaskListener
- Direct Known Subclasses:
BigIntegerNumberInputDialog,NumberInputDialog
A base class for prompting users to enter a number into this dialog
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected JLabelprotected BigIntegerprotected BigIntegerprotected IntegerTextFieldprotected booleanFields inherited from class docking.DialogComponentProvider
applyButton, buttonPanel, cancelButton, dismissButton, okButton, rootPanel -
Constructor Summary
ConstructorsConstructorDescriptionAbstractNumberInputDialog(String title, String prompt, Integer initialValue, int min, int max, boolean showAsHex) Show a number input dialogAbstractNumberInputDialog(String title, String prompt, BigInteger initialValue, BigInteger min, BigInteger max, boolean showAsHex) Show a number input dialog -
Method Summary
Modifier and TypeMethodDescriptionprotected static StringbuildDefaultPrompt(String entryType, int min, int max) protected JPanelbuildMainPanel(String prompt, boolean showAsHex) Define the Main panel for the dialog hereprotected voidGets called when the user clicks on the Cancel Action for the dialog.Get the current input valueintGet the current input value as an intlongGet the current input value as a longintgetMax()Return the maximum acceptable value.intgetMin()Return the minimum acceptable value.protected voidGets called when the user clicks on the OK Action for the dialog.voidsetDefaultMessage(String defaultMessage) Sets the default message to be displayed when valid values are in the text fields.voidsetInput(int value) Sets the value in the input field to the indicated value.booleanshow()showdisplays the dialog, gets the user inputprotected static BigIntegerprotected voidbooleanReturn whether the user cancelled the input dialogMethods inherited from class docking.DialogComponentProvider
addAction, addApplyButton, addButton, addCancelButton, addDismissButton, addOKButton, addWorkPanel, alertMessage, alertMessage, applyCallback, cancelCurrentTask, clearScheduledTask, clearStatusText, close, closeDialog, createSharedActions, dialogClosed, dialogShown, dismissCallback, dispose, doInitialize, escapeCallback, executeProgressTask, getActionContext, getActions, getBackground, getBounds, getComponent, getDefaultButton, getDefaultSize, getDialogSize, getFocusComponent, getGlassPane, getHelpLocation, getId, getInitialLocation, getLocationOnScreen, getParent, getPreferredSize, getRememberLocation, getRememberSize, getStatusColor, getStatusLabel, getStatusText, getTaskMonitorComponent, getTaskScheduler, getTitle, getUseSharedLocation, hideTaskMonitorComponent, isApplyEnabled, isCancelEnabled, isDialogKeyBindingAction, isModal, isOKEnabled, isResizeable, isRunningTask, isShowing, isTransient, isVisible, notifyContextChanged, removeAction, removeButton, removeWorkPanel, repack, setAccessibleDescription, setApplyEnabled, setApplyToolTip, setBackground, setCancelButtonText, setCancelEnabled, setCancelToolTip, setCursor, setDefaultButton, setDefaultSize, setDialogSize, setDismissToolTip, setFocusComponent, setGlassPane, setHelpLocation, setInitialLocation, setMinimumSize, setMinimumSize, setOkButtonText, setOkEnabled, setOkToolTip, setPreferredSize, setRememberLocation, setRememberSize, setResizable, setStatusJustification, setStatusText, setStatusText, setStatusText, setTitle, setTransient, setUseSharedLocation, showProgressBar, showTaskMonitorComponent, stopProgressTimer, taskCancelled, taskCompleted, toFront, toString, waitForCurrentTask
-
Field Details
-
wasCancelled
protected boolean wasCancelled -
numberInputField
-
min
-
max
-
label
-
defaultMessage
-
-
Constructor Details
-
AbstractNumberInputDialog
public AbstractNumberInputDialog(String title, String prompt, Integer initialValue, int min, int max, boolean showAsHex) Show a number input dialog- Parameters:
title- The title of the dialogprompt- the prompt to display before the number input fieldinitialValue- the default value to display, null will leave the field blankmin- the minimum allowed value of the fieldmax- the maximum allowed value of the fieldshowAsHex- if true, the initial value will be displayed as hex
-
AbstractNumberInputDialog
public AbstractNumberInputDialog(String title, String prompt, BigInteger initialValue, BigInteger min, BigInteger max, boolean showAsHex) Show a number input dialog- Parameters:
title- The title of the dialogprompt- the prompt to display before the number input fieldinitialValue- the default value to display, null will leave the field blankmin- the minimum allowed value of the fieldmax- the maximum allowed value of the fieldshowAsHex- if true, the initial value will be displayed as hex
-
-
Method Details
-
buildMainPanel
Define the Main panel for the dialog here- Parameters:
prompt- the prompt label textshowAsHex- if true, show the value as hex- Returns:
- JPanel the completed
Main Panel
-
okCallback
protected void okCallback()Gets called when the user clicks on the OK Action for the dialog.- Overrides:
okCallbackin classDialogComponentProvider
-
cancelCallback
protected void cancelCallback()Gets called when the user clicks on the Cancel Action for the dialog.- Overrides:
cancelCallbackin classDialogComponentProvider
-
wasCancelled
public boolean wasCancelled()Return whether the user cancelled the input dialog- Returns:
- true if cancelled
-
getBigIntegerValue
Get the current input value- Returns:
- the value
- Throws:
NumberFormatException- if entered value cannot be parsedIllegalStateException- if the dialog was cancelled
-
getLongValue
public long getLongValue()Get the current input value as a long- Returns:
- the value
- Throws:
NumberFormatException- if entered value cannot be parsedIllegalStateException- if the dialog was cancelledArithmeticException- if the value in this field will not fit into a long
-
getIntValue
public int getIntValue()Get the current input value as an int- Returns:
- the value
- Throws:
NumberFormatException- if entered value cannot be parsedIllegalStateException- if the dialog was cancelledArithmeticException- if the value in this field will not fit into an int
-
show
public boolean show()showdisplays the dialog, gets the user input- Returns:
- false if the user cancelled the operation
-
setInput
public void setInput(int value) Sets the value in the input field to the indicated value.- Parameters:
value- the value
-
setDefaultMessage
Sets the default message to be displayed when valid values are in the text fields.- Parameters:
defaultMessage- the message to be displayed when valid values are in the text fields.
-
getMin
public int getMin()Return the minimum acceptable value.- Returns:
- the min
-
getMax
public int getMax()Return the maximum acceptable value.- Returns:
- the max
-
updateOKButtonEnablement
protected void updateOKButtonEnablement() -
buildDefaultPrompt
-
toBig
-