Java Reference
In-Depth Information
package class MyPackageClass {
}
A class may also be declared abstract , meaning that this class cannot be instan-
tiated directly, but can only be instantiated using one of its subclasses. Abstract
classes are not intended to stand on their own, but encapsulate a portion of
shared state and functions that several classes may use. Only a subclass of an
abstract class can be instantiated, and typically the subclass has to fill in those
unique states or behavior not addressed in the abstract class.
public abstract class MyAbstractClass {
}
If a class declares an abstract function, it must be declared abstract .
public abstract class AnotherAbstractClass {
public abstract function
setXY(x:Number, y:Number) : Void;
}
Mixin Classes
JavaFX supports a form of inheritance called mixin inheritance. To support this,
JavaFX includes a special type of class called a mixin . A mixin class is a class
that provides certain functionality to be inherited by subclasses. They cannot be
instantiated on their own. A mixin class is different from a Java interface in that
the mixin may provide default implementations for its functions and also may
declare and initialize its own variables.
To declare a mixin class in JavaFX, you need to include the mixin keyword in
the class declaration. The following code shows this.
public mixin class Positioner {
A mixin class may contain any number of function declarations. If the function
declaration has a function body, then this is the default implementation for the
function. For example, the following listing shows a mixin class declaration for
a class that positions one node within another.
public mixin class Positioner {
protected bound function centerX(
node: Node, within: Node) : Number {
 
Search WWH ::




Custom Search