DhcpmgrDialog.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*/
/**
* This abstract class provides a framework for building all of the dialogs
* used by DHCP Mgr. Subclasses must implement the abstract methods defined
* here as well as override any other appropriate methods. Most of these
* methods are declared protected because they are implementation details
* which need not be visible outside the dialog we're actually implementing.
*/
public abstract class DhcpmgrDialog extends JDialog
implements ButtonPanelListener {
// Listeners receive action events when user presses OK
// ButtonPanel is protected so subclasses can manipulate directly
protected ButtonPanel buttonPanel;
super(f);
// Layout is subclass main panel, then a separator, then buttons
// Create buttonPanel first so subclasses can modify it if need be
// Position relative to our owning frame
}
/**
* Return the main display panel
*/
protected abstract JPanel getMainPanel();
public void addActionListener(ActionListener l) {
listeners.addElement(l);
}
public void removeActionListener(ActionListener l) {
}
/**
* fire the action event
*/
protected abstract void fireActionPerformed();
command);
while (en.hasMoreElements()) {
l.actionPerformed(e);
}
}
/**
* Handle user clicks on the dialog buttons
*/
public void buttonPressed(int buttonId) {
switch (buttonId) {
case OK:
doOk();
break;
case CANCEL:
doCancel();
break;
case HELP:
doHelp();
break;
case RESET:
doReset();
break;
default:
break;
}
}
/**
* Handle user pressing OK button
*/
protected abstract void doOk();
/**
* Handle user pressing Cancel button, default is to disappear
*/
protected void doCancel() {
setVisible(false);
dispose();
}
/**
* Handle user pressing Reset; this default implementation does
* nothing, subclasses should override.
*/
protected void doReset() {
// Do nothing
}
/**
* Handle user pressing Help
*/
protected void doHelp() {
}
/**
* Return the help key
*/
protected abstract String getHelpKey();
}