thinwire.ui
Class MessageBox

java.lang.Object
  extended by thinwire.ui.MessageBox

public final class MessageBox
extends java.lang.Object

A MessageBox displays a message (or a component) and allows a user to respond.

Example:

 MessageBox.confirm("resources/ngLF/info.png", "ThinWire",
         "Get ready for ThinWire");
 

Keyboard Navigation:

KEY RESPONSE NOTE


Constructor Summary
MessageBox()
           
 
Method Summary
 void close()
          Close the message box.
static void closeCurrent()
          Closes the current message box.
 int confirm()
          Make the MessageBox visible, and then block.
static void confirm(java.lang.String message)
          Display a dialog window with an OK button and message.
static void confirm(java.lang.String title, java.lang.String message)
          Display a dialog window with an OK button, title and message.
static int confirm(java.lang.String icon, java.lang.String title, Component component, java.lang.String buttons)
          Display a dialog window with the specified icon, title, component, and buttons.
static void confirm(java.lang.String icon, java.lang.String title, java.lang.String message)
          Display a dialog window with an OK button, icon, title and message.
static int confirm(java.lang.String icon, java.lang.String title, java.lang.String message, java.lang.String buttons)
          Display a dialog window with specified buttons, message and icons.
 java.lang.String getButtons()
          Returns the string that sets all the buttons for the message box.
 Component getComponent()
          Returns the component for the MessageBox.
 java.lang.String getIcon()
          Returns the icon for the message box.
 java.lang.String getText()
          Returns the message in the message box.
 java.lang.String getTitle()
          Returns the title of the MessageBox.
 void setButtons(java.lang.String buttons)
          Sets the buttons based on a string.
 void setComponent(Component component)
          Set the component for the MessageBox.
 void setIcon(java.lang.String icon)
          Set the icon for the MessageBox.
 void setText(java.lang.String text)
          Set the message for the MessageBox.
 void setTitle(java.lang.String title)
          Set the title for the MessageBox.
 void show()
          Makes the MessageBox visible.
static void show(java.lang.String message)
          Display a dialog window without buttons.
static void show(java.lang.String title, java.lang.String message)
          Display a dialog window without buttons.
static void show(java.lang.String icon, java.lang.String title, java.lang.String message)
          Display a dialog window without buttons.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageBox

public MessageBox()
Method Detail

show

public static void show(java.lang.String message)
Display a dialog window without buttons.

Adds the MessageBox to the MessageBox stack on the application instance.
This method will not block.
For multiple line messages, separate the lines with "\n".

Parameters:
message - The dialog message, a \n separated sequence of lines.

show

public static void show(java.lang.String title,
                        java.lang.String message)
Display a dialog window without buttons.

Adds the MessageBox to the MessageBox stack on the application instance.
This method will not block.
For multiple line messages, separate the lines with "\n".

Parameters:
title - the dialog title
message - The dialog message, a \n separated sequence of lines.

show

public static void show(java.lang.String icon,
                        java.lang.String title,
                        java.lang.String message)
Display a dialog window without buttons.

Adds the MessageBox to the MessageBox stack on the application instance.
This method will not block.
For multiple line messages, separate the lines with "\n".

Parameters:
icon - name of the image file without path info or file extension.
title - the dialog title
message - The dialog message, a \n separated sequence of lines.

confirm

public static void confirm(java.lang.String message)
Display a dialog window with an OK button and message.

Sample usage:

 MessageBox.confirm("Invalid Return by Time\nInvalid Zip Code");
 
For multiple line messages, separate the lines with "\n".

Parameters:
message - The dialog message, a \n separated sequence of lines.

confirm

public static void confirm(java.lang.String title,
                           java.lang.String message)
Display a dialog window with an OK button, title and message.

Sample usage:

 MessageBox.confirm("Operator Message", 
   "Invalid Return by Time\nInvalid Zip Code");
 
For multiple line messages, separate the lines with "\n".

Parameters:
title - the dialog title
message - The dialog message, a \n separated sequence of lines.

confirm

public static void confirm(java.lang.String icon,
                           java.lang.String title,
                           java.lang.String message)
Display a dialog window with an OK button, icon, title and message.

Sample usage:

 MessageBox.confirm("error", "Operator Message", 
   "Invalid Return by Time\nInvalid Zip Code");
 
For multiple line messages, separate the lines with "\n".

Parameters:
icon - name of the image file without path info or file extension.
title - the dialog title
message - The dialog message, a \n separated sequence of lines.

confirm

public static int confirm(java.lang.String icon,
                          java.lang.String title,
                          java.lang.String message,
                          java.lang.String buttons)
Display a dialog window with specified buttons, message and icons.

Sample usage:

 MessageBox.confirm("question", "Operator Message",
                "Would you like to shut down the server?", 
      "text1;image1|text2,image2");
 
For multiple line messages, separate the lines with "\n".

The buttons string should specify text and optionally an image for each button. Use a semi-colon to separate the text and image for a button, and a pipe to separate one button's info from that of the next.
e.g. "text1;image1|text2;image2|......|textk;imagek"

The buttons string can also specify int return values for the buttons.
e.g. "text1;image1;5|text2;image2;17|......|textK;imageK;27"

Warning: Give all of the buttons return values or none of them. If you don't specify return values, a button's return value will depend on the order in which it is added to the dialog. Also, return values must be integers greater than or equal to 0.

Parameters:
icon - The dialog's icon.
title - The dialog's title.
message - The dialog's message.
buttons - specifies what text and icon each button will have
Returns:
the clicked button's return value

confirm

public static int confirm(java.lang.String icon,
                          java.lang.String title,
                          Component component,
                          java.lang.String buttons)
Display a dialog window with the specified icon, title, component, and buttons.

Parameters:
icon - the name of the icon, optional
title - the MessageBox title
component - the Component for the content panel.
buttons - a string specifying the buttons
Returns:
the clicked button's return value

closeCurrent

public static void closeCurrent()
Closes the current message box.


getTitle

public java.lang.String getTitle()
Returns the title of the MessageBox.

Returns:
the title of this MessageBox

setTitle

public void setTitle(java.lang.String title)
Set the title for the MessageBox.

Parameters:
title - the MessageBox title

getText

public java.lang.String getText()
Returns the message in the message box.

Returns:
the message in this MessageBox

setText

public void setText(java.lang.String text)
Set the message for the MessageBox.

For multiple line messages, separate the lines with "\n".
Don't set both a message and a Component.

Parameters:
text - the message

getComponent

public Component getComponent()
Returns the component for the MessageBox.

Returns:
a Component

setComponent

public void setComponent(Component component)
Set the component for the MessageBox.

The component will appear in the content panel.
Don't set both a message and a Component.

Parameters:
component - the content for the MessageBox.

getIcon

public java.lang.String getIcon()
Returns the icon for the message box.

Returns:
the name for the icon for the MessageBox

setIcon

public void setIcon(java.lang.String icon)
Set the icon for the MessageBox. It appears in the top left corner.

Parameters:
icon - name of the icon

getButtons

public java.lang.String getButtons()
Returns the string that sets all the buttons for the message box.

Returns:
the string describing this MessageBox's buttons

setButtons

public void setButtons(java.lang.String buttons)
Sets the buttons based on a string.

Example:
 currentMB.setButtons("Delete;ERASE|Activate;STAR|Cancel;CANCEL");
 

Parameters:
buttons - a String describing the buttons

show

public void show()
Makes the MessageBox visible.

Adds the MessageBox to the MessageBox stack on the application instance.

This method is non-blocking.


confirm

public int confirm()
Make the MessageBox visible, and then block.

Returns:
the clicked button's return value

close

public void close()
Close the message box.



ThinWire® is a registered of Custom Credit Systems  Copyright © 2007 All rights reserved.
ThinWire_is_Open_Source_under_the_terms_of_the_LGPLv2.1 SourceForge.net_Project_Page java.net_Member Support_ThinWire,_Digg_our_Story