Oracle JEWT 4.2.10

oracle.bali.ewt.dialog
Class JEWTDialog

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--javax.swing.JDialog
                                |
                                +--oracle.bali.ewt.dialog.JEWTDialog
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class JEWTDialog
extends javax.swing.JDialog

JEWTDialog is a JDialog subclass that contains the properly look for the OracleLookAndFeel. JEWTDialog will also look correct in other LookAndFeels.

JEWTDialog will display buttons at the bottom of the dialog like OK, cancel, help and apply, as well as the contents of the dialog above the buttons with the correct insets as determined by Oracle's User Interface team.

To set the buttons that are visible call setButtonMask() and use a bit mask of the BUTTON_* constants.

To set the contents of the JEWTDialog use setContent().

To display the dialog call runDialog(). runDialog() will return true if the dialog was closed by pressing ok and false otherwise.

Users can add custom buttons that will be displayed in the button area by calling addCustomButton().

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Inner classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static java.lang.String ACTION_APPLY
          ActionEvent command that is sent when the apply button is pressed.
static int BUTTON_APPLY
          Constant representing the apply button.
static int BUTTON_CANCEL
          Constant representing the cancel button.
static int BUTTON_DEFAULT
          Constant representing all default buttons.
static int BUTTON_HELP
          Constant representing the help button.
static int BUTTON_NONE
          Constant representing no button.
static int BUTTON_OK
          Constant representing the OK button.
static java.lang.String PROPERTY_CLOSED
          Dialog Closing Property (used in the PropertyChangeEvent)
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JEWTDialog()
          Creates a modal JEWTDialog with the default title and without a specified Frame owner.
JEWTDialog(java.awt.Dialog owner)
          Creates a modal JEWTDialog with the default title with the specifed Dialog as its owner.
JEWTDialog(java.awt.Dialog owner, java.lang.String title)
          Creates a modal JEWTDialog with the specified title and with the specified owner dialog.
JEWTDialog(java.awt.Dialog owner, java.lang.String title, int buttonMask)
          Creates a modal JEWTDialog with the specified title and with the specified owner dialog.
JEWTDialog(java.awt.Frame owner)
          Creates a modal JEWTDialog with the default title with the specifed Frame as its owner.
JEWTDialog(java.awt.Frame owner, java.lang.String title)
          Creates a modal JEWTDialog with the specified title and with the specified owner frame.
JEWTDialog(java.awt.Frame owner, java.lang.String title, int buttonMask)
          Creates a modal JEWTDialog with the specified title and with the specified owner frame.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Add an ActionListener to listen for action events from the apply button.
 void addCustomButton(java.awt.Component button)
          Add a custom button to the button bar.
 void addNotify()
          Notifies the component that it has been added to a container.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Adds a VetoableChangeListener to the listener list.
static JEWTDialog createDialog(java.awt.Component owner, java.lang.String title, int buttonMask)
          Use this method to construct a JEWTDialog which automatically parents itself correctly on either a Dialog or Frame.
protected  void dialogInit()
          Override to init dialog.
protected  void dismissDialog(boolean cancelled)
          Hides the dialog.
 void dispose()
          Override to free memory.
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Fire a PropertyChangeEvent for the given propertyName and it's old and new values.
protected  void fireVetoableChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Supports reporting constrained property changes.
 int getButtonMask()
          The buttonMask, a bitwise or of the button constants
 int getCancelButtonMnemonic()
          Gets the mnemonic of cancel button or -1 if the cancel button is not included in the button mask.
 java.lang.String getCancelButtonText()
          Gets the caption of cancel button or null if the cancel button is not included in the button mask.
 java.awt.Component getCenterOver()
          Returns the component over which the dialog will be centered.
 java.awt.Component getContent()
          Get the content Component in this dialog.
 java.awt.Component getCustomButton(int button)
          Get a particular custom button
 int getCustomButtonCount()
          The number of current custom buttons.
 int getDefaultButton()
          Get the constant representing the default focused button
 java.awt.Component getInitialFocus()
          Returns the component that will receive focus initially.
 int getOKButtonMnemonic()
          Gets the mnemonic of ok button or -1 if the ok button is not included in the button mask.
 java.lang.String getOKButtonText()
          Gets the caption of ok button or null if the ok button is not included in the button mask.
 java.awt.Dimension getPreferredSize()
          Get the preferredSize of the JEWTDialog.
 boolean isCancelled()
          Returns true if the dialog was cancelled from its last run.
static boolean isDialogClosingEvent(java.beans.PropertyChangeEvent evt)
          Utility method to determine if the PropertyChangeEvent is the event used in validation.
 boolean isOKButtonEnabled()
          Get the enabled state of the OK button
 void pack()
          Override to fix a bug on Linux.
protected  void processActionEvent(java.awt.event.ActionEvent e)
          Send action events to all registered listeners.
protected  void processComponentEvent(java.awt.event.ComponentEvent e)
          Override to not allow resizing smaller than initial size.
protected  void processEvent(java.awt.AWTEvent e)
          Override to look for ActionEvents.
protected  void processWindowEvent(java.awt.event.WindowEvent e)
          Processes window events occurring on this window.
 void removeActionListener(java.awt.event.ActionListener listener)
          Remove an ActionListener.
 void removeCustomButton(java.awt.Component button)
          Remove a custom button from the button bar.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
          Removes a VetoableChangeListener from the listener list.
 boolean runDialog()
          Runs the JEWTDialog until it is either cancelled or finishes succesfully.
 void setButtonMask(int mask)
          Choose which buttons (OK, Cancel, Help, Apply) to add.
 void setCancelButtonMnemonic(int keyCode)
          Sets the mnemonic of cancel button.
 void setCancelButtonText(java.lang.String translatedText)
          Sets the caption of cancel button.
 void setCenterOver(java.awt.Component centerOver)
          Sets the component over which the dialog will be centered.
 void setContent(java.awt.Component content)
          Set the content Component in this dialog.
 void setDefaultButton(int button)
          Sets the default focused button
 void setInitialFocus(java.awt.Component initialFocus)
          Sets the component that will receive focus initially.
 void setOKButtonEnabled(boolean enabled)
          Sets the enabled state of the OK button
 void setOKButtonMnemonic(int keyCode)
          Sets the mnemonic of ok button.
 void setOKButtonText(java.lang.String translatedText)
          Sets the caption of ok button.
 void setPreferredSize(java.awt.Dimension prefSize)
          Set the preferredSize of the JEWTDialog.
 void setPreferredSize(int width, int height)
          Set the preferredSize of the JEWTDialog.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setLocationRelativeTo, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
getTitle, hide, isModal, isResizable, setModal, setResizable, setTitle, show
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, finalize, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isShowing, postEvent, removeWindowListener, setCursor, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUTTON_NONE

public static final int BUTTON_NONE
Constant representing no button.

BUTTON_OK

public static final int BUTTON_OK
Constant representing the OK button.

BUTTON_CANCEL

public static final int BUTTON_CANCEL
Constant representing the cancel button.

BUTTON_HELP

public static final int BUTTON_HELP
Constant representing the help button.

BUTTON_APPLY

public static final int BUTTON_APPLY
Constant representing the apply button.

BUTTON_DEFAULT

public static final int BUTTON_DEFAULT
Constant representing all default buttons.
See Also:
BUTTON_OK, BUTTON_CANCEL, BUTTON_HELP

PROPERTY_CLOSED

public static final java.lang.String PROPERTY_CLOSED
Dialog Closing Property (used in the PropertyChangeEvent)

ACTION_APPLY

public static final java.lang.String ACTION_APPLY
ActionEvent command that is sent when the apply button is pressed.
Constructor Detail

JEWTDialog

public JEWTDialog()
Creates a modal JEWTDialog with the default title and without a specified Frame owner. A shared, hidden frame will be set as the owner of the JEWTDialog .

JEWTDialog

public JEWTDialog(java.awt.Frame owner)
Creates a modal JEWTDialog with the default title with the specifed Frame as its owner.
Parameters:
owner - the Frame from which the dialog is displayed

JEWTDialog

public JEWTDialog(java.awt.Frame owner,
                  java.lang.String title)
Creates a modal JEWTDialog with the specified title and with the specified owner frame.
Parameters:
owner - the Frame from which the dialog is displayed
title - the String to display in the dialog's title bar

JEWTDialog

public JEWTDialog(java.awt.Frame owner,
                  java.lang.String title,
                  int buttonMask)
Creates a modal JEWTDialog with the specified title and with the specified owner frame.
Parameters:
owner - the Frame from which the dialog is displayed
title - the String to display in the dialog's title bar
buttonMask - bitwise combination of button constants

JEWTDialog

public JEWTDialog(java.awt.Dialog owner)
Creates a modal JEWTDialog with the default title with the specifed Dialog as its owner.
Parameters:
owner - the Dialog from which the dialog is displayed

JEWTDialog

public JEWTDialog(java.awt.Dialog owner,
                  java.lang.String title)
Creates a modal JEWTDialog with the specified title and with the specified owner dialog.
Parameters:
owner - the Dialog from which the dialog is displayed
title - the String to display in the dialog's title bar

JEWTDialog

public JEWTDialog(java.awt.Dialog owner,
                  java.lang.String title,
                  int buttonMask)
Creates a modal JEWTDialog with the specified title and with the specified owner dialog.
Parameters:
owner - the Dialog from which the dialog is displayed
title - the String to display in the dialog's title bar
buttonMask - bitwise combination of button constants
Method Detail

createDialog

public static JEWTDialog createDialog(java.awt.Component owner,
                                      java.lang.String title,
                                      int buttonMask)
Use this method to construct a JEWTDialog which automatically parents itself correctly on either a Dialog or Frame.
Parameters:
owner - The owner component for the dialog. The first Dialog or Frame ancestor of this component will be used as the parent of the dialog. If this parameter is null, or none of the ancestors of owner are Dialogs or Frames, an invisible frame is used as the parent
title - The String to display in the dialog's title bar
buttonMask - bitwise combination of button constants
Returns:
A newly instantiated JEWTDialog

getCenterOver

public java.awt.Component getCenterOver()
Returns the component over which the dialog will be centered.

setCenterOver

public void setCenterOver(java.awt.Component centerOver)
Sets the component over which the dialog will be centered.

isCancelled

public boolean isCancelled()
Returns true if the dialog was cancelled from its last run. If the dialog is currently visible, always returns false.

runDialog

public boolean runDialog()
Runs the JEWTDialog until it is either cancelled or finishes succesfully.
Returns:
false if the JEWTDialog was cancelled, true if it finished succesfully. For non-modal dialogs, always returns true.

dispose

public void dispose()
Override to free memory.
Overrides:
dispose in class java.awt.Dialog

setPreferredSize

public final void setPreferredSize(java.awt.Dimension prefSize)
Set the preferredSize of the JEWTDialog.

setPreferredSize

public void setPreferredSize(int width,
                             int height)
Set the preferredSize of the JEWTDialog. This should not exceed the standard defined by the UI team which will soon by 800x600. If the preferredSize is larger than 800x600 width and height will be adjusted accordingly.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Get the preferredSize of the JEWTDialog. This will not exceed the standard defined by the UI team which will soon by 800x600. If the default preferredSize is larger than 800x600 width and height will be adjusted accordingly.
Overrides:
getPreferredSize in class java.awt.Container

getContent

public java.awt.Component getContent()
Get the content Component in this dialog.

setContent

public void setContent(java.awt.Component content)
Set the content Component in this dialog.

getButtonMask

public int getButtonMask()
The buttonMask, a bitwise or of the button constants

setButtonMask

public void setButtonMask(int mask)
Choose which buttons (OK, Cancel, Help, Apply) to add.
Parameters:
mask - Bitwise or of any of BUTTON_OK, BUTTON_CANCEL, BUTTON_HELP, and BUTTON_APPLY

addCustomButton

public void addCustomButton(java.awt.Component button)
Add a custom button to the button bar.

removeCustomButton

public void removeCustomButton(java.awt.Component button)
Remove a custom button from the button bar.

getCustomButtonCount

public int getCustomButtonCount()
The number of current custom buttons.

getCustomButton

public java.awt.Component getCustomButton(int button)
Get a particular custom button

getDefaultButton

public int getDefaultButton()
Get the constant representing the default focused button

setDefaultButton

public void setDefaultButton(int button)
Sets the default focused button
Parameters:
the - button constant

setOKButtonEnabled

public void setOKButtonEnabled(boolean enabled)
Sets the enabled state of the OK button

isOKButtonEnabled

public boolean isOKButtonEnabled()
Get the enabled state of the OK button

setOKButtonText

public void setOKButtonText(java.lang.String translatedText)
Sets the caption of ok button. If translatedText contains an '&' character than that character will be used as the mnemonic for the button.

Parameters:
translatedText - the text for the button's caption.

getOKButtonText

public java.lang.String getOKButtonText()
Gets the caption of ok button or null if the ok button is not included in the button mask.
Returns:
the Caption on the button

getOKButtonMnemonic

public int getOKButtonMnemonic()
Gets the mnemonic of ok button or -1 if the ok button is not included in the button mask.
Returns:
the mnemonic keycode of the button

setOKButtonMnemonic

public void setOKButtonMnemonic(int keyCode)
Sets the mnemonic of ok button.
Parameters:
keyCode - the mnemonic keycode of the button

setCancelButtonText

public void setCancelButtonText(java.lang.String translatedText)
Sets the caption of cancel button. If translatedText contains an '&' character than that character will be used as the mnemonic for the button.

Parameters:
translatedText - the text for the button's caption.

getCancelButtonText

public java.lang.String getCancelButtonText()
Gets the caption of cancel button or null if the cancel button is not included in the button mask.
Returns:
the Caption on the button

getCancelButtonMnemonic

public int getCancelButtonMnemonic()
Gets the mnemonic of cancel button or -1 if the cancel button is not included in the button mask.
Returns:
the mnemonic keycode of the button

setCancelButtonMnemonic

public void setCancelButtonMnemonic(int keyCode)
Sets the mnemonic of cancel button.
Parameters:
keyCode - the mnemonic keycode of the button

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Add an ActionListener to listen for action events from the apply button. The command will be ACTION_APPLY.

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Remove an ActionListener.

addNotify

public void addNotify()
Notifies the component that it has been added to a container. This method should be called by Container.add, and never by user code directly.
Overrides:
addNotify in class java.awt.Dialog

getInitialFocus

public java.awt.Component getInitialFocus()
Returns the component that will receive focus initially.

setInitialFocus

public void setInitialFocus(java.awt.Component initialFocus)
Sets the component that will receive focus initially.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.
Overrides:
addPropertyChangeListener in class java.awt.Component
Parameters:
listener - the PropertyChangeListener to be added

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
Overrides:
removePropertyChangeListener in class java.awt.Component
Parameters:
listener - the PropertyChangeListener to be removed

addVetoableChangeListener

public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list. The listener is registered for all properties.
Parameters:
listener - the VetoableChangeListener to be added

removeVetoableChangeListener

public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list. This removes a VetoableChangeListener that was registered for all properties.
Parameters:
listener - the VetoableChangeListener to be removed

isDialogClosingEvent

public static boolean isDialogClosingEvent(java.beans.PropertyChangeEvent evt)
Utility method to determine if the PropertyChangeEvent is the event used in validation. The property changed when the dialog is about to close is PROPERTY_CLOSED. This follows the behavior of javax.swing.JInternalFrame.
Parameters:
evt - The change event.
Returns:
true if this event is the dialog closing. and false otherwise.

pack

public void pack()
Override to fix a bug on Linux.
Overrides:
pack in class java.awt.Window

processComponentEvent

protected void processComponentEvent(java.awt.event.ComponentEvent e)
Override to not allow resizing smaller than initial size.
Overrides:
processComponentEvent in class java.awt.Component

dialogInit

protected void dialogInit()
Override to init dialog.
Overrides:
dialogInit in class javax.swing.JDialog

processWindowEvent

protected void processWindowEvent(java.awt.event.WindowEvent e)
Processes window events occurring on this window.
Overrides:
processWindowEvent in class javax.swing.JDialog
Parameters:
e - the window event

fireVetoableChange

protected void fireVetoableChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
                           throws java.beans.PropertyVetoException
Supports reporting constrained property changes. This method can be called when a constrained property has changed and it will send the appropriate PropertyChangeEvent to any registered VetoableChangeListeners.
Throws:
java.beans.PropertyVetoException - when the attempt to set the property is vetoed by the receiver.

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Fire a PropertyChangeEvent for the given propertyName and it's old and new values.
Overrides:
firePropertyChange in class java.awt.Component

dismissDialog

protected void dismissDialog(boolean cancelled)
Hides the dialog.
Parameters:
cancelled - true if the cancel button was pressed, false if the finish button was pressed.

processEvent

protected void processEvent(java.awt.AWTEvent e)
Override to look for ActionEvents.
Overrides:
processEvent in class java.awt.Window

processActionEvent

protected void processActionEvent(java.awt.event.ActionEvent e)
Send action events to all registered listeners.

Oracle JEWT 4.2.10