Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit
Class Dialog

java.lang.Object
  extended by com.sun.dtv.lwuit.Component
      extended by com.sun.dtv.lwuit.Container
          extended by com.sun.dtv.lwuit.Form
              extended by com.sun.dtv.lwuit.Dialog
All Implemented Interfaces:
Animation, StyleListener, Animated, MatteEnabled

public class Dialog
extends Form

A dialog is a form that occupies a part of the screen and appears as a modal entity to the developer. Dialogs allow us to prompt users for information and rely on the information being available on the next line after the show method.

Modality indicates that a dialog will block the calling thread even if the calling thread is the EDT. Notice that a dialog will not release the block until dispose is called even if show() from another form is called!

To determine the size of the dialog use the show method that accepts 4 integer values, notice that these values accept margin from the four sides rather than x, y, width and height values!

To style the dialog you would usually want to style the content pane rather than the dialog itself.


Field Summary
static int TYPE_ALARM
          Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.
static int TYPE_CONFIRMATION
          Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.
static int TYPE_ERROR
          Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.
static int TYPE_INFO
          Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.
static int TYPE_WARNING
          Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.
 
Fields inherited from class com.sun.dtv.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Fields inherited from interface com.sun.dtv.ui.Animated
ALTERNATING, LOOP, REPEATING
 
Constructor Summary
Dialog()
          Constructs a Dialog with a title.
Dialog(String title)
          Constructs a Dialog with a title.
 
Method Summary
 boolean animate()
          Allows the animation to reduce "repaint" calls when it returns false.
 void dispose()
          Closes the current form and returns to the previous form, releasing the EDT in the process.
static String getDefaultDialogPosition()
          Default screen orientation position for the upcoming dialog.
 Style getDialogStyle()
          Simple getter to get the Dialog Style.
 boolean isAutoDispose()
          Determines whether the execution of a command on this dialog implicitly disposes the dialog.
 void refreshTheme()
          Makes sure the component is up to date with the current style object.
 void setAutoDispose(boolean autoDispose)
          Determines whether the execution of a command on this dialog implicitly disposes the dialog.
static void setDefaultDialogPosition(String p)
          Default screen orientation position for the upcoming dialog.
 void setDialogStyle(Style style)
          Simple setter to set the Dialog Style.
 void setTimeout(long time)
          Indicates the time (in milliseconds) after which the dialog will be disposed implicitly.
 void show()
          The default version of show modal shows the dialog occupying the center portion of the screen.
 Command show(int top, int bottom, int left, int right, boolean includeTitle)
          This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box.
 Command show(int top, int bottom, int left, int right, boolean includeTitle, boolean modal)
          This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box.
static Command show(String title, Component body, Command[] cmds)
          Shows a modal dialog with the given component as its "body" placed in the center.
static Command show(String title, Component body, Command[] cmds, int type, Image icon)
          Shows a modal dialog with the given component as its "body" placed in the center.
static Command show(String title, Component body, Command[] cmds, int type, Image icon, long timeout)
          Shows a modal dialog with the given component as its "body" placed in the center.
static Command show(String title, Component body, Command[] cmds, int type, Image icon, long timeout, Transition transition)
          Shows a modal dialog with the given component as its "body" placed in the center.
static Command show(String title, Component body, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout, Transition transition)
          Shows a modal dialog with the given component as its "body" placed in the center.
static Command show(String title, String text, Command[] cmds, int type, Image icon, long timeout)
          Shows a modal prompt dialog with the given title and text.
static Command show(String title, String text, Command[] cmds, int type, Image icon, long timeout, Transition transition)
          Shows a modal prompt dialog with the given title and text.
static Command show(String title, String text, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout)
          Shows a modal prompt dialog with the given title and text.
static Command show(String title, String text, Command defaultCommand, Command[] cmds, int type, Image icon, long timeout, Transition transition)
          Shows a modal prompt dialog with the given title and text.
static boolean show(String title, String text, int type, Image icon, String okText, String cancelText)
          Shows a modal prompt dialog with the given title and text.
static boolean show(String title, String text, int type, Image icon, String okText, String cancelText, long timeout)
          Shows a modal prompt dialog with the given title and text.
static boolean show(String title, String text, String okText, String cancelText)
          Shows a modal prompt dialog with the given title and text.
 Command showDialog()
          Shows a modal dialog and returns the command pressed within the modal dialog.
 void showModeless()
          Shows a modeless dialog which is useful for some simpler use cases such as progress indication etc...
 Command showPacked(String position, boolean modal)
          Convenience method to show a dialog sized to match its content.
 
Methods inherited from class com.sun.dtv.lwuit.Form
addCommand, addCommand, addComponent, addComponent, addComponent, addGameKeyListener, addKeyListener, deregisterAnimation, getBackCommand, getClearCommand, getCommand, getCommandCount, getComponentForm, getContentPane, getDefaultCommand, getFocused, getGlassPane, getScrollAnimationSpeed, getSoftButton, getSoftButtonCount, getSoftButtonStyle, getTintColor, getTitle, getTitleComponent, getTitleStyle, getTransitionInAnimator, getTransitionOutAnimator, hideNotify, isSingleFocusMode, isSmoothScrolling, keyPressed, keyReleased, keyRepeated, longKeyPress, onShow, paint, paintBackground, pointerDragged, pointerPressed, pointerReleased, registerAnimation, removeAll, removeAllCommands, removeCommand, removeComponent, removeGameKeyListener, removeKeyListener, replace, scrollComponentToVisible, setBackCommand, setBgImage, setClearCommand, setCommandListener, setDefaultCommand, setFocused, setGlassPane, setLayout, setMenuCellRenderer, setMenuTransitions, setScrollable, setScrollableX, setScrollableY, setScrollAnimationSpeed, setSmoothScrolling, setSoftButtonStyle, setTintColor, setTitle, setTitleStyle, setTransitionInAnimator, setTransitionOutAnimator, setVisible, showMenuDialog, showNotify, sizeChanged
 
Methods inherited from class com.sun.dtv.lwuit.Container
contains, doLayout, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getLayout, getLayoutHeight, getLayoutWidth, getMatte, invalidate, isScrollableX, isScrollableY, layoutContainer, revalidate, setCellRenderer, setMatte
 
Methods inherited from class com.sun.dtv.lwuit.Component
addFocusListener, calcPreferredSize, contains, deinitialize, getAbsoluteX, getAbsoluteY, getAnimationMode, getBaseline, getBaselineResizeBehavior, getBottomGap, getBounds, getClientProperty, getDelay, getHeight, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPosition, getPreferredSize, getRepetitionMode, getScrollX, getScrollY, getSideGap, getStyle, getUIID, getWidth, getX, getY, handlesInput, hasFocus, initialize, isEnabled, isFocusable, isFocusPainted, isInitialized, isRunning, isScrollVisible, isVisible, jumpTo, paintBackgrounds, paintComponent, paintComponent, putClientProperty, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, setAnimationMode, setDelay, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredSize, setRepetitionMode, setScrollX, setScrollY, setShouldCalcPreferredSize, setSize, setStyle, setUIID, setWidth, setX, setY, start, stop, styleChanged, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_ALARM

public static final int TYPE_ALARM
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.

See Also:
Constant Field Values

TYPE_CONFIRMATION

public static final int TYPE_CONFIRMATION
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.

See Also:
Constant Field Values

TYPE_ERROR

public static final int TYPE_ERROR
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.

See Also:
Constant Field Values

TYPE_INFO

public static final int TYPE_INFO
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.

See Also:
Constant Field Values

TYPE_WARNING

public static final int TYPE_WARNING
Constant indicating the type of alert to indicate the sound to play or icon if none are explicitly set.

See Also:
Constant Field Values
Constructor Detail

Dialog

public Dialog(String title)
Constructs a Dialog with a title.

Parameters:
title - the title of the dialog

Dialog

public Dialog()
Constructs a Dialog with a title.

Method Detail

setDialogStyle

public void setDialogStyle(Style style)
Simple setter to set the Dialog Style. There is a significant difference between the purpose of this method and the setStyle method as inherited from Component! While setStyle influences the style of the whole screen, this method refers to the style of the content pane, where all the elements of the dialog are visible.

Parameters:
style - the style
See Also:
getDialogStyle(), Component.setStyle(com.sun.dtv.lwuit.plaf.Style)

getDialogStyle

public Style getDialogStyle()
Simple getter to get the Dialog Style. There is a significant difference between the purpose of this method and the getStyle method as inherited from Component! While getStyle returns the style of the whole screen, this method refers to the style of the content pane, where all the elements of the dialog are visible.

Returns:
the style
See Also:
setDialogStyle(com.sun.dtv.lwuit.plaf.Style), Component.getStyle()

show

public Command show(int top,
                    int bottom,
                    int left,
                    int right,
                    boolean includeTitle)
This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box. This method will block the calling thread even if the calling thread is the EDT. Notice that this method will not release the block until dispose is called even if show() from another form is called!

Modal dialogs Allow the forms "content" to "hang in mid air" this is especially useful for dialogs where you would want the underlying form to "peek" from behind the form.

Parameters:
top - space in pixels between the top of the screen and the form
bottom - space in pixels between the bottom of the screen and the form
left - space in pixels between the left of the screen and the form
right - space in pixels between the right of the screen and the form
includeTitle - whether the title should hang in the top of the screen or be glued onto the content pane
Returns:
the last command pressed by the user if such a command exists

show

public Command show(int top,
                    int bottom,
                    int left,
                    int right,
                    boolean includeTitle,
                    boolean modal)
This method shows the form as a modal alert allowing us to produce a behavior of an alert/dialog box. This method will block the calling thread even if the calling thread is the EDT. Notice that this method will not release the block until dispose is called even if show() from another form is called!

Modal dialogs Allow the forms "content" to "hang in mid air" this is especially useful for dialogs where you would want the underlying form to "peek" from behind the form.

Parameters:
top - space in pixels between the top of the screen and the form
bottom - space in pixels between the bottom of the screen and the form
left - space in pixels between the left of the screen and the form
right - space in pixels between the right of the screen and the form
includeTitle - whether the title should hang in the top of the screen or be glued onto the content pane
modal - indicates the dialog should be modal set to false for modeless dialog which is useful for some use cases
Returns:
the last command pressed by the user if such a command exists

setTimeout

public void setTimeout(long time)
Indicates the time (in milliseconds) after which the dialog will be disposed implicitly.

Parameters:
time - a milliseconds time used to dispose the dialog

show

public static boolean show(String title,
                           String text,
                           int type,
                           Image icon,
                           String okText,
                           String cancelText)
Shows a modal prompt dialog with the given title and text.

Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
okText - the text to appear in the command dismissing the dialog
cancelText - optionally null for a text to appear in the cancel command for canceling the dialog
Returns:
true if the ok command was pressed or if cancelText is null. False otherwise.

show

public static boolean show(String title,
                           String text,
                           int type,
                           Image icon,
                           String okText,
                           String cancelText,
                           long timeout)
Shows a modal prompt dialog with the given title and text.

Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
okText - the text to appear in the command dismissing the dialog
cancelText - optionally null for a text to appear in the cancel command for canceling the dialog
timeout - a timeout after which null would be returned if timeout is 0 infinite time is used
Returns:
true if the ok command was pressed or if cancelText is null. False otherwise.

show

public static Command show(String title,
                           String text,
                           Command[] cmds,
                           int type,
                           Image icon,
                           long timeout)
Shows a modal prompt dialog with the given title and text.

Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
cmds - commands that are added to the form any click on any command will dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 infinite time is used
Returns:
the command pressed by the user

show

public static Command show(String title,
                           String text,
                           Command defaultCommand,
                           Command[] cmds,
                           int type,
                           Image icon,
                           long timeout)
Shows a modal prompt dialog with the given title and text.

Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
defaultCommand - command to be assigned as the default command or null
cmds - commands that are added to the form any click on any command will dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 infinite time is used
Returns:
the command pressed by the user

show

public static Command show(String title,
                           String text,
                           Command[] cmds,
                           int type,
                           Image icon,
                           long timeout,
                           Transition transition)
Shows a modal prompt dialog with the given title and text.

Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
cmds - commands that are added to the form any click on any command will dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 infinite time is used
transition - the transition installed when the dialog enters/leaves
Returns:
the command pressed by the user

show

public static Command show(String title,
                           String text,
                           Command defaultCommand,
                           Command[] cmds,
                           int type,
                           Image icon,
                           long timeout,
                           Transition transition)
Shows a modal prompt dialog with the given title and text.

Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
defaultCommand - command to be assigned as the default command or null
cmds - commands that are added to the form any click on any command will dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 infinite time is used
transition - the transition installed when the dialog enters/leaves
Returns:
the command pressed by the user

show

public static boolean show(String title,
                           String text,
                           String okText,
                           String cancelText)
Shows a modal prompt dialog with the given title and text.

Parameters:
title - The title for the dialog optionally null;
text - the text displayed in the dialog
okText - the text to appear in the command dismissing the dialog
cancelText - optionally null for a text to appear in the cancel command for canceling the dialog
Returns:
true if the ok command was pressed or if cancelText is null. False otherwise.

show

public static Command show(String title,
                           Component body,
                           Command[] cmds)
Shows a modal dialog with the given component as its "body" placed in the center.

Parameters:
title - title for the dialog
body - component placed in the center of the dialog
cmds - commands that are added to the form any click on any command will dispose the form
Returns:
the command pressed by the user

show

public static Command show(String title,
                           Component body,
                           Command[] cmds,
                           int type,
                           Image icon)
Shows a modal dialog with the given component as its "body" placed in the center.

Parameters:
title - title for the dialog
body - component placed in the center of the dialog
cmds - commands that are added to the form any click on any command will dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
Returns:
the command pressed by the user

show

public static Command show(String title,
                           Component body,
                           Command[] cmds,
                           int type,
                           Image icon,
                           long timeout)
Shows a modal dialog with the given component as its "body" placed in the center.

Parameters:
title - title for the dialog
body - component placed in the center of the dialog
cmds - commands that are added to the form any click on any command will dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 infinite time is used
Returns:
the command pressed by the user

show

public static Command show(String title,
                           Component body,
                           Command[] cmds,
                           int type,
                           Image icon,
                           long timeout,
                           Transition transition)
Shows a modal dialog with the given component as its "body" placed in the center.

Parameters:
title - title for the dialog
body - component placed in the center of the dialog
cmds - commands that are added to the form any click on any command will dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 infinite time is used
transition - the transition installed when the dialog enters/leaves
Returns:
the command pressed by the user

show

public static Command show(String title,
                           Component body,
                           Command defaultCommand,
                           Command[] cmds,
                           int type,
                           Image icon,
                           long timeout,
                           Transition transition)
Shows a modal dialog with the given component as its "body" placed in the center.

Parameters:
title - title for the dialog
body - component placed in the center of the dialog
defaultCommand - command to be assigned as the default command or null
cmds - commands that are added to the form any click on any command will dispose the form
type - the type of the alert one of TYPE_WARNING, TYPE_INFO, TYPE_ERROR, TYPE_CONFIRMATION or TYPE_ALARM
icon - the icon for the dialog, can be null
timeout - a timeout after which null would be returned if timeout is 0 infinite time is used
transition - the transition installed when the dialog enters/leaves
Returns:
the command pressed by the user

show

public void show()
The default version of show modal shows the dialog occupying the center portion of the screen.

Overrides:
show in class Form

showModeless

public void showModeless()
Shows a modeless dialog which is useful for some simpler use cases such as progress indication etc...


showPacked

public Command showPacked(String position,
                          boolean modal)
Convenience method to show a dialog sized to match its content.

Parameters:
position - one of the values from the BorderLayout class e.g. BorderLayout.CENTER, BorderLayout.NORTH etc.
modal - whether the dialog should be modal
Returns:
the command selected if the dialog is modal and disposed via a command

dispose

public void dispose()
Closes the current form and returns to the previous form, releasing the EDT in the process.


refreshTheme

public void refreshTheme()
Description copied from class: Component
Makes sure the component is up to date with the current style object.

Overrides:
refreshTheme in class Form

showDialog

public Command showDialog()
Shows a modal dialog and returns the command pressed within the modal dialog.

Returns:
last command pressed in the modal dialog

animate

public boolean animate()
Description copied from interface: Animation
Allows the animation to reduce "repaint" calls when it returns false. It is called once for every frame.

Specified by:
animate in interface Animation
Overrides:
animate in class Component
Returns:
true if a repaint is desired or false if no repaint is necessary

isAutoDispose

public boolean isAutoDispose()
Determines whether the execution of a command on this dialog implicitly disposes the dialog. This defaults to true which is a sensible default for simple dialogs.

Returns:
whether the execution of a command on this dialog implicitly disposes the dialog

setAutoDispose

public void setAutoDispose(boolean autoDispose)
Determines whether the execution of a command on this dialog implicitly disposes the dialog. This defaults to true which is a sensible default for simple dialogs.

Parameters:
autoDispose - auto disposed state

setDefaultDialogPosition

public static void setDefaultDialogPosition(String p)
Default screen orientation position for the upcoming dialog. By default the dialog will be shown at hardcoded coordinates, this method allows us to pack the dialog appropriately in one of the border layout based locations see BorderLayout for further details.

Parameters:
p - default dialog position
See Also:
getDefaultDialogPosition()

getDefaultDialogPosition

public static String getDefaultDialogPosition()
Default screen orientation position for the upcoming dialog. By default the dialog will be shown at hardcoded coordinates, this method allows us to pack the dialog appropriately in one of the border layout based locations see BorderLayout for further details.

Returns:
default dialog position
See Also:
setDefaultDialogPosition(java.lang.String)

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.