Package adams.terminal.dialog
Class ComponentDialog
- java.lang.Object
-
- com.googlecode.lanterna.gui2.AbstractBasePane<com.googlecode.lanterna.gui2.Window>
-
- com.googlecode.lanterna.gui2.AbstractWindow
-
- com.googlecode.lanterna.gui2.dialogs.DialogWindow
-
- adams.terminal.dialog.ComponentDialog
-
- All Implemented Interfaces:
com.googlecode.lanterna.gui2.BasePane
,com.googlecode.lanterna.gui2.Composite
,com.googlecode.lanterna.gui2.Window
public class ComponentDialog extends com.googlecode.lanterna.gui2.dialogs.DialogWindow
Dialog for displaying a component.- Version:
- $Revision$
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description ComponentDialog(String title, String description, com.googlecode.lanterna.gui2.Component component)
Default constructor, takes a title for the dialog and runs code shared for dialogs Shows OK and Cancel buttons.ComponentDialog(String title, String description, com.googlecode.lanterna.gui2.Component component, boolean hasOK, boolean hasCancel, boolean hasClose)
Default constructor, takes a title for the dialog and runs code shared for dialogsComponentDialog(String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
Default constructor, takes a title for the dialog and runs code shared for dialogs Shows OK and Cancel buttons.ComponentDialog(String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints, boolean hasOK, boolean hasCancel, boolean hasClose)
Default constructor, takes a title for the dialog and runs code shared for dialogs
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.googlecode.lanterna.gui2.dialogs.MessageDialogButton
getResult()
Returns the button that was selected.protected void
onCancel()
protected void
onClose()
protected void
onOK()
void
setSize(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, double width, double height)
Sets the width and height of the dialog according to the percentage of the overall available screen real estate.com.googlecode.lanterna.gui2.dialogs.MessageDialogButton
showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI)
Shows the dialog.static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton
showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component)
Shortcut for quickly showing aOptionDialog
.static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton
showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, boolean hasOK, boolean hasCancel, boolean hasClose)
Shortcut for quickly showing aOptionDialog
.static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton
showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
Shortcut for quickly showing aOptionDialog
.static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton
showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints, boolean hasOK, boolean hasCancel, boolean hasClose)
Shortcut for quickly showing aOptionDialog
.-
Methods inherited from class com.googlecode.lanterna.gui2.AbstractWindow
addWindowListener, close, draw, fromGlobal, getDecoratedSize, getHints, getPosition, getPostRenderer, getPreferredSize, getSize, getTextGUI, getTitle, handleInput, isVisible, removeWindowListener, setCloseWindowWithEscape, setContentOffset, setDecoratedSize, setHints, setPosition, setSize, setTextGUI, setTitle, setVisible, setWindowPostRenderer, toGlobal, waitUntilClosed
-
Methods inherited from class com.googlecode.lanterna.gui2.AbstractBasePane
addBasePaneListener, getBasePaneListeners, getComponent, getCursorPosition, getFocusedInteractable, getTheme, invalidate, isInvalid, removeBasePaneListener, setComponent, setEnableDirectionBasedMovements, setFocusedInteractable, setFocusedInteractable, setStrictFocusChange, setTheme
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
ComponentDialog
public ComponentDialog(String title, String description, com.googlecode.lanterna.gui2.Component component)
Default constructor, takes a title for the dialog and runs code shared for dialogs Shows OK and Cancel buttons.- Parameters:
title
- Title of the windowdescription
- the optional description, can be nullcomponent
- the component to display
-
ComponentDialog
public ComponentDialog(String title, String description, com.googlecode.lanterna.gui2.Component component, boolean hasOK, boolean hasCancel, boolean hasClose)
Default constructor, takes a title for the dialog and runs code shared for dialogs- Parameters:
title
- Title of the windowdescription
- the optional description, can be nullcomponent
- the component to displayhasOK
- whether to display the OK buttonhasCancel
- whether to display the Cancel buttonhasClose
- whether to display the Close button
-
ComponentDialog
public ComponentDialog(String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
Default constructor, takes a title for the dialog and runs code shared for dialogs Shows OK and Cancel buttons.- Parameters:
title
- Title of the windowdescription
- the optional description, can be nullcomponent
- the component to displayhints
- the window hints
-
ComponentDialog
public ComponentDialog(String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints, boolean hasOK, boolean hasCancel, boolean hasClose)
Default constructor, takes a title for the dialog and runs code shared for dialogs- Parameters:
title
- Title of the windowdescription
- the optional description, can be nullcomponent
- the component to displayhints
- the window hintshasOK
- whether to display the OK buttonhasCancel
- whether to display the Cancel buttonhasClose
- whether to display the Close button
-
-
Method Detail
-
setSize
public void setSize(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, double width, double height)
Sets the width and height of the dialog according to the percentage of the overall available screen real estate.- Parameters:
textGUI
- for determining the maximum dimensionswidth
- the width percentage (0-1) or number of columns (> 1)height
- the height percentage (0-1) or number of rows (> 1)
-
onOK
protected void onOK()
-
onCancel
protected void onCancel()
-
onClose
protected void onClose()
-
showDialog
public com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI)
Shows the dialog.- Overrides:
showDialog
in classcom.googlecode.lanterna.gui2.dialogs.DialogWindow
- Parameters:
textGUI
- the context- Returns:
- the button that was selected
-
getResult
public com.googlecode.lanterna.gui2.dialogs.MessageDialogButton getResult()
Returns the button that was selected.- Returns:
- the button
-
showDialog
public static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component)
Shortcut for quickly showing aOptionDialog
. Shows OK and Cancel buttons.- Parameters:
textGUI
- GUI to show the dialog ontitle
- Title of the dialogdescription
- Description of the dialogcomponent
- the component- Returns:
- the button that was selected
-
showDialog
public static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints)
Shortcut for quickly showing aOptionDialog
. Shows OK and Cancel buttons.- Parameters:
textGUI
- GUI to show the dialog ontitle
- Title of the dialogdescription
- Description of the dialogcomponent
- the componenthints
- the window hints- Returns:
- the button that was selected
-
showDialog
public static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, boolean hasOK, boolean hasCancel, boolean hasClose)
Shortcut for quickly showing aOptionDialog
.- Parameters:
textGUI
- GUI to show the dialog ontitle
- Title of the dialogdescription
- Description of the dialogcomponent
- the componenthasOK
- whether to display the OK buttonhasCancel
- whether to display the Cancel buttonhasClose
- whether to display the Close button- Returns:
- the button that was selected
-
showDialog
public static com.googlecode.lanterna.gui2.dialogs.MessageDialogButton showDialog(com.googlecode.lanterna.gui2.WindowBasedTextGUI textGUI, String title, String description, com.googlecode.lanterna.gui2.Component component, Collection<com.googlecode.lanterna.gui2.Window.Hint> hints, boolean hasOK, boolean hasCancel, boolean hasClose)
Shortcut for quickly showing aOptionDialog
.- Parameters:
textGUI
- GUI to show the dialog ontitle
- Title of the dialogdescription
- Description of the dialogcomponent
- the componenthints
- the window hintshasOK
- whether to display the OK buttonhasCancel
- whether to display the Cancel buttonhasClose
- whether to display the Close button- Returns:
- the button that was selected
-
-