package view;
/**
* A second level descendant class of AFrame
* that initializes itself by calling the
* initialize() method of its direct superclass
* in addition to its own initialization code.
*/
public class FrameAB extends FrameA {
/**
* Calls the superclass constructor, FrameA,
* which in turns calls its superclass constructor,
* AFrame, which first calls its superclass
* constructor, JFrame, and then executes the
* initialize() method of this FrameAB.
*/
public FrameAB(String title) {
super(title);
}
/**
* At run-time, when the constructor AFrame is
* executed, it calls this FrameAB initialize()
* method and NOT the initialize() method of the
* superclass FrameA. In order to reuse the
* initialization code for FrameA, we must make
* the super call to initialize().
*/
protected void initialize() {
// Call initialize() of FrameA:
super.initialize();
/**
* Additional application specific intialization
* code for FraemAB goes here...
*/
}
}
|
package view;
/**
* A second level descendant class of AFrame
* that bypasses the initialize() method of
* its direct superclass in its own
* initialization code. Since proper
* initialization of a subclass depends on
* proper initialization of the super class,
* bypassing the initialization code of the
* superclass is a BAD idea!
*/
public class FrameAC extends FrameA {
/**
* Calls the superclass constructor, FrameA,
* which in turns calls its superclass constructor,
* AFrame, which first calls its superclass
* constructor, JFrame, and then executes the
* initialize() method of this FrameAC.
*/
public FrameAC(String title) {
super(title);
}
/**
* At run-time, when the constructor AFrame is
* executed, it calls this initialize() method and
* NOT the initialize() method of the superclass
* FrameA. This method does not call the super
* class's initialize() method. As a result, the
* initialization done in the superclass is
* bypassed completely. This is a BAD idea!
*/
protected void initialize() {
/**
* Application specific intialization code for
* FraemAB goes here...
*/
}
}
|