kiwi.ui.dialog
Class ComponentDialog

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--javax.swing.JDialog
                                |
                                +--kiwi.ui.dialog.KDialog
                                      |
                                      +--kiwi.ui.dialog.ComponentDialog
Direct Known Subclasses:
DateChooserDialog, DirectorySelectorDialog, KInputDialog, KMessageDialog, KQuestionDialog, LoginDialog, PropertyEditorDialog

public abstract class ComponentDialog
extends KDialog

A base class for custom dialog windows. This class provides some base functionality that can be useful across many different types of dialogs. The class constructs a skeleton dialog consisting of an optional comment line, an icon, OK and Cancel buttons, and a middle area that must be filled in by subclassers.

A ComponentDialog is accepted by clicking the OK button, though subclassers can determine the conditions under which a dialog may be accepted by overriding the accept() method; it is cancelled by clicking the Cancel button or closing the window.

Version:
1.1.2 (11/98)
Author:
Mark Lindner, PING Software Group
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Field Summary
protected  KButton b_cancel
          The Cancel button.
protected  KButton b_ok
          The OK button.
 
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
 
Constructor Summary
ComponentDialog(Frame parent, String title, boolean modal)
          Construct a new ComponentDialog.
ComponentDialog(Frame parent, String title, boolean modal, boolean hasCancel)
          Construct a new ComponentDialog.
 
Method Summary
protected  boolean accept()
          Accept user input.
protected  void addButton(JButton button)
          Add a button to the dialog's button panel.
protected  void addButton(JButton button, int pos)
          Add a button to the dialog's button panel at the specified position.
protected abstract  Component buildDialogUI()
          Construct the component that will be displayed in the center of the dialog window.
protected  void cancel()
          Cancel the dialog.
 boolean isCancelled()
          Get the cancelled state of the dialog.
 void pack()
          This is overridden to fix a Swing layout bug.
protected  void registerTextInputComponent(JTextField c)
          Register a text field with this dialog.
protected  void removeButton(int pos)
          Remove a button from the specified position in the dialog's button panel.
protected  void removeButton(JButton button)
          Remove a button from the dialog's button panel.
 void setAcceptButtonText(String text)
          Set the label text for the OK button.
 void setCancelButtonText(String text)
          Set the label text for the Cancel button.
protected  void setComment(String comment)
          Change the dialog's comment.
 void setIcon(Icon icon)
          Get the icon to display in the left part of the dialog window.
 void setVisible(boolean flag)
          Show or hide the dialog.
 
Methods inherited from class kiwi.ui.dialog.KDialog
addDialogDismissListener, dispose, fireDialogDismissed, fireDialogDismissed, getMainContainer, removeDialogDismissListener, setTexture
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processWindowEvent, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setLocationRelativeTo, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, getTitle, isModal, isResizable, setModal, setResizable, setTitle, show
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, finalize, getFocusOwner, getInputContext, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isShowing, postEvent, processEvent, removeWindowListener, 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, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, 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, hide, 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, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

b_ok

protected KButton b_ok
The OK button.

b_cancel

protected KButton b_cancel
The Cancel button.
Constructor Detail

ComponentDialog

public ComponentDialog(Frame parent,
                       String title,
                       boolean modal)
Construct a new ComponentDialog.
Parameters:
parent - The parent frame for this dialog.
title - The title for this dialog's window.
modal - A flag specifying whether this dialog will be modal.

ComponentDialog

public ComponentDialog(Frame parent,
                       String title,
                       boolean modal,
                       boolean hasCancel)
Construct a new ComponentDialog.
Parameters:
parent - The parent frame for this dialog.
title - The title for this dialog's window.
modal - A flag specifying whether this dialog will be modal.
hasCancel - A flag specifying whether this dialog should have a Cancel button.
Method Detail

buildDialogUI

protected abstract Component buildDialogUI()
Construct the component that will be displayed in the center of the dialog window. Subclassers implement this method to customize the look of the dialog.
Returns:
A Component to display in the dialog.

setVisible

public void setVisible(boolean flag)
Show or hide the dialog.
Overrides:
setVisible in class Component

registerTextInputComponent

protected void registerTextInputComponent(JTextField c)
Register a text field with this dialog. In some dialogs, most notably KInputDialog, pressing Return in a text field is equivalent to pressing the dialog's OK button. Subclassers may use this method to register a text field that should function in this way.
Parameters:
c - The JTextField to register.

pack

public void pack()
This is overridden to fix a Swing layout bug.
Overrides:
pack in class Window

setComment

protected void setComment(String comment)
Change the dialog's comment.
Parameters:
comment - The new text to display in the comment portion of the dialog.

setIcon

public void setIcon(Icon icon)
Get the icon to display in the left part of the dialog window. By default, this method returns null, which signifies that no icon will be displayed. The method can be called by classes that extend this class to provide an appropriate icon for the dialog.
Returns:
A Icon to display in the dialog.

isCancelled

public boolean isCancelled()
Get the cancelled state of the dialog. This method should be called after the dialog is dismissed to determine if it was cancelled by the user.
Returns:
true if the dialog was cancelled, and false otherwise.

accept

protected boolean accept()
Accept user input. The dialog calls this method in response to a click on the dialog's OK button. If this method returns true, the dialog disappears; otherwise, it remains on the screen. This method can be overridden to check input in the dialog before allowing it to be dismissed. The default implementation of this method returns true.
Returns:
true if the dialog may be dismissed, and false otherwise.

cancel

protected void cancel()
Cancel the dialog. The dialog calls this method in response to a click on the dialog's Cancel button, or on a close of the dialog window itself. Subclassers may override this method to provide any special processing that is required when the dialog is cancelled. The default implementation of this method does nothing.

addButton

protected void addButton(JButton button)
Add a button to the dialog's button panel. The button is added immediately before the OK button.
Parameters:
button - The button to add.

addButton

protected void addButton(JButton button,
                         int pos)
                  throws IllegalArgumentException
Add a button to the dialog's button panel at the specified position.
Parameters:
button - The button to add.
pos - The position at which to add the button. A value of 0 denotes the first position, and -1 denotes the last position. The possible range of values for pos excludes the OK and (if present) Cancel buttons; buttons may not be added after these "fixed" buttons.

removeButton

protected void removeButton(JButton button)
Remove a button from the dialog's button panel.
Parameters:
button - The button to remove. Neither the OK nor the Cancel button may be removed.

removeButton

protected void removeButton(int pos)
Remove a button from the specified position in the dialog's button panel.
Parameters:
button - The button to remove.
pos - The position of the button to remove, where 0 denotes the first position, and -1 denotes the last position. The possible range of values for pos excludes the OK and (if present) Cancel buttons; these "fixed" buttons may not be removed.

setAcceptButtonText

public void setAcceptButtonText(String text)
Set the label text for the OK button.
Parameters:
text - The text for the accept button (for example, "Yes").

setCancelButtonText

public void setCancelButtonText(String text)
Set the label text for the Cancel button.
Parameters:
text - The text for the cancel button (for example, "No").