If enum type cannot be subclassed, using MouseWheelEvent and MouseEvent
as an example where the former is the latter's subclass, how can the
constants be made into enum type?
Static constants from MouseEvent:
static int MOUSE_CLICKED
static int MOUSE_DRAGGED
// etc
// ...
Static constants from MouseWheelEvent:
static int WHEEL_BLOCK_SCROLL
static int WHEEL_UNIT_SCROLL
or is enum type not applicable in this matter? if so, when is enum
applicable?
Chris Smith - 24 Jul 2005 05:24 GMT
> If enum type cannot be subclassed, using MouseWheelEvent and MouseEvent
> as an example where the former is the latter's subclass, how can the
> constants be made into enum type?
...
> or is enum type not applicable in this matter? if so, when is enum
> applicable?
Enumerations are definitely not applicable in that case. There are
several reasons for enums, but the one Java chose to focus on is type
safety; an enum guarantees that the variable will not have any value
except those listed. The ability to subclass and add more possible
values would violate that guarantee, because those values would need to
be assignment-compatible with the supertype.
Where are enums applicable? Anywhere you have a set of possible values
that you DO want to enforce strictly.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Roedy Green - 24 Jul 2005 10:14 GMT
>If enum type cannot be subclassed, using MouseWheelEvent and MouseEvent
>as an example where the former is the latter's subclass, how can the
>constants be made into enum type?
Each enum constant can be its own inner anonymous class with its own
methods and member variables.
Just write something like this
enum { RED( a, b, c ) { void m( x ) { ...} },
m is a method of inner class RED which is also an enum constant.
a, b, c are parms to its constructor.

Signature
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes