For my icons in Swing i've different enums like:
public enum Icon32 {
STOP("resources/icons/x32/stop.ico"),
RUN("resources/icons/x32/run.ico");
private File path;
private Icon32(String path) {
this.path = new File(path);
}
public File getFile() {
return path;
}
or
public enum Tab {
XML("resources/icons/x32/tab/tab_1.ico"), QR("resources/icons/x32/tab/tab_2.ico"),ABOUT("resources/icons/x32/tab/tab_3.ico");
private File path;
private Tab(String path) {
this.path = new File(path);
}
public File getFile() {
return path;
}
}
I've created an abstract implementation:
public abstract class AbstractImageType {
private File path;
private AbstractImageType(String path) {
this.path = new File(path);
}
public File getFile() {
return path;
}
@Override
public String toString() {
return path.toString();
}
}
But Enum is not possible to extend:
Syntax error on token "extends", implements expected
Now my question, is it possible to make a generic class "AbstractImageType" whos implementing the method(s) and constructor? so i've only to insert the Enum values?
Something like this:
public enum Icon32 extends AbstractImageType {
STOP("resources/icons/x32/stop.ico"),
RUN("resources/icons/x32/run.ico");
}