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.


Variable Index

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

Constructor Index

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

Method Index

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

Variables

 o okButton

  public Button okButton
OK button.

 o applyButton

  public Button applyButton
Apply button.

 o cancelButton

  public Button cancelButton
Cancel button.

 o drawArea

  public JCOutlinePanel drawArea
Main draw area, which is the body of the dialog.

 o buttonArea

  public JCOutlinePanel buttonArea
Button panel. Add custom buttons here.

Constructors

 o JCDialog

  public JCDialog(Frame parent,
                  String title)
Constructs a JCDialog instance for the OK and Cancel buttons.
Parameters:
parent - the parent frame
title - the title of the dialog box

 o JCDialog

  public JCDialog(Frame parent,
                  String title,
                  boolean apply)
This constructs a JCDialog instance for the OK, Apply and Cancel buttons.
Parameters:
parent - the parent frame
title - the title of the dialog box
apply - if true, the Apply button is added

Methods

 o getParentFrame

  public Frame getParentFrame()
This is used to access the parent frame.

 o 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

 o 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

 o clear

  public void clear()
Default implementation of a member to clear the dialog.

 o 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

 o 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