    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class jclass.contrib.JCDialog

    java.lang.Object
       |
       +----java.awt.Component
               |
               +----java.awt.Container
                       |
                       +----java.awt.Window
                               |
                               +----java.awt.Frame
                                       |
                                       +----jclass.contrib.JCDialog

public class JCDialog
extends Frame
implements JCDialogCB

JCDialog implements an OK/CANCEL dialog. By default, JCDialog is made up of a drawArea and a buttonArea containing an okButton, an applyButton, and a cancelButton. These members are accessible by all.

JCDialogCB supports two callback methods. The first method is to subclass JCDialog and override the buttonCB() member function. The second methos is to implement the JCDialogCB interface and provide an implementation of the same buttonCB() member function, and then use the setButtonCB() member to register the receiver with the JCDialog class. In both cases, a return of false enables the default callback failure (usually unmapping or hiding).

Adding items to JCDialog is done through the drawArea member. It is an instance of JCOutlinePanel, and is derived from the AWT panel.

The following is an example of how to use JCDialog:

    class QuitBox extends JCDialog {
    public QuitBox(Frame fg) {
    super(fg, "Quit Application?");
    drawArea.setLayout(new JCRowColLayout(1, 1));
    drawArea.add(new Label("Quit Application?"));
    okButton.setLabel("Yes");
    cancelButton.setLabel("No");
    }
    public boolean buttonCB(JCDialog d, Button b) {
    if (b == okButton)
    System.exit(0);
    return handleEvent(new Event(this, Event.WINDOW_DESTROY, null));
    }
    }

In this example, the "override" technique is used. Note that the button labels are changed to "Yes" and "No".

JCDialog does not support modal dialogs.

##

applyButton
  Apply button.
buttonArea
  TButton panel.
cancelButton
  Cancel button.
drawArea
  Main draw area, which is the body of the dialog.
okButton
  OK button.

##

JCDialog(Component, String)
  Constructs a JCDialog instance for the OK and Cancel buttons.
JCDialog(Component, String, boolean)
  This constructs a JCDialog instance for the OK, Apply, and Cancel buttons.

##

buttonCB(JCDialog, Button)
  Default implementation of the button callback.
clear()
  Default implementation of a member to clear the dialog.
getParentFrame()
  This is used to access the parent frame.
handleEvent(Event)
  Local event handler.
setButtonCB(JCDialogCB)
  Registers a callback recipient for the dialog.
show()
  The Overridden Component.show() member.

##

okButton

      public Button okButton

  OK button.

applyButton

      public Button applyButton

  Apply button.

cancelButton

      public Button cancelButton

  Cancel button.

drawArea

      public JCOutlinePanel drawArea

  Main draw area, which is the body of the dialog.

buttonArea

      public JCOutlinePanel buttonArea

  TButton panel. Add custom buttons here.

##

JCDialog

      public JCDialog(Component parent,
                      String title)

  Constructs a JCDialog instance for the OK and Cancel buttons.

  Parameters:
    parent - the parent component, used to position the dialog; if not a Frame, the component's parent frame is found
    title - the title of the dialog box

JCDialog

      public JCDialog(Component parent,
                      String title,
                      boolean apply)

  This constructs a JCDialog instance for the OK, Apply, and Cancel buttons.

  Parameters:
    parent - the parent component, used to position the dialog; if not a Frame, the component's parent frame is found
    title - the title of the dialog box
    apply - if true, the Apply button is added

##

getParentFrame

      public Frame getParentFrame()

  This is used to access the parent frame.

show

      public synchronized void show()

  The Overridden Component.show() member. It guarantees the peer has been allocated and attempts to position the dialog relative to the parent dialog.

  Overrides:
    show in class Window

setButtonCB

      public void setButtonCB(JCDialogCB target)

  Registers a callback recipient for the dialog. There can only be one callback recipient per dialog. Recipient must implement the JCDialogCB interface.

  Parameters:
    target - the instance of an object implementing the JCDialogCB interface

clear

      public void clear()

  Default implementation of a member to clear the dialog.

buttonCB

      public boolean buttonCB(JCDialog d,
                              Button b)

  Default implementation of the button callback.

  Parameters:
    d - the dialog in which the callback occurred
    b - the button that was pressed

handleEvent

      public boolean handleEvent(Event event)

  Local event handler. It sends button events to the registered callback recipient. If none were registered, the buttonCB() member of the current object is called instead. Note that if the button callbacks return false, the default handling is performed.

  Overrides:
    handleEvent in class Component

    All Packages  Class Hierarchy  This Package  Previous  Next  Index