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
Modifier and TypeFieldDescriptionprotected String
protected JLabel
protected BigInteger
protected BigInteger
protected IntegerTextField
protected boolean
Fields inherited from class docking.DialogComponentProvider
applyButton, buttonPanel, cancelButton, dismissButton, okButton, rootPanel
-
Constructor Summary
ConstructorDescriptionAbstractNumberInputDialog
(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 String
buildDefaultPrompt
(String entryType, int min, int max) protected JPanel
buildMainPanel
(String prompt, boolean showAsHex) Define the Main panel for the dialog hereprotected void
Gets called when the user clicks on the Cancel Action for the dialog.Get the current input valueint
Get the current input value as an intlong
Get the current input value as a longint
getMax()
Return the maximum acceptable value.int
getMin()
Return the minimum acceptable value.protected void
Gets called when the user clicks on the OK Action for the dialog.void
setDefaultMessage
(String defaultMessage) Sets the default message to be displayed when valid values are in the text fields.void
setInput
(int value) Sets the value in the input field to the indicated value.boolean
show()
show
displays the dialog, gets the user inputprotected static BigInteger
protected void
boolean
Return 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, 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, 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:
okCallback
in classDialogComponentProvider
-
cancelCallback
protected void cancelCallback()Gets called when the user clicks on the Cancel Action for the dialog.- Overrides:
cancelCallback
in 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()show
displays 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
-