Typesafe enum properties
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ian_Carter
Posted On:   Friday, June 24, 2005 05:36 AM

I'm having BIG problems with JB 2005's designer when using typesafe enum properties of a javabean. Whenever I try to go into the UI designer from Source I get the following error:- "java.lang.ClassNotFoundException: .LottoStyle createDefaultPropertyEditor(.LottoStyle)" where LottoStyle is my typesafe enum class. Source follows:- public class LottoStyle implements Comparable { private final String style; // Ordinal of next style to be created private static int nextOrdinal = 1; // Assign an ordinal to this style private final int ordinal = nextOrdinal++; private LottoStyle(String style) { this.style = style; } public String toString() { re   More>>

I'm having BIG problems with JB 2005's designer when using typesafe enum properties of a javabean. Whenever I try to go into the UI designer from Source I get the following error:-

"java.lang.ClassNotFoundException: .LottoStyle createDefaultPropertyEditor(.LottoStyle)"

where LottoStyle is my typesafe enum class. Source follows:-


			
public class LottoStyle implements Comparable {
private final String style;
// Ordinal of next style to be created
private static int nextOrdinal = 1;
// Assign an ordinal to this style
private final int ordinal = nextOrdinal++;

private LottoStyle(String style) { this.style = style; }

public String toString() { return style; }

public boolean equals(Object obj) {
if (!(obj instanceof LottoStyle)) {
return false;
}
if (obj == this) {
return true;
}
return obj.toString().equals(toString());
}

public int compareTo(Object obj) {
return ordinal - ((LottoStyle)obj).ordinal;
}

public static final LottoStyle LOTTOLINE = new LottoStyle("Lotto Line");
public static final LottoStyle EUROMILLIONS = new LottoStyle("EuroMillions");
public static final LottoStyle THUNDERBALL = new LottoStyle("ThunderBall");
public static final LottoStyle HOTPICKS = new LottoStyle("Hot Picks");
public static final LottoStyle LOTTORESULT = new LottoStyle("Lotto Result");
}


I've implemented an editor for the property. Source follows:-


			import java.beans.PropertyEditorSupport;
			

public class LottoStyleEditor extends PropertyEditorSupport {
protected String value;

public LottoStyleEditor() {
super();
value = "Lotto Line";
}

public String[] getTags() {
return new String[] { "Lotto Line", "EuroMillions", "ThunderBall",
"Hot Picks", "Lotto Result" };
}

public void setAsText(String val) {
if (val == "EuroMillions") {
setValue(LottoStyle.EUROMILLIONS);
} else if (val == "ThunderBall") {
setValue(LottoStyle.THUNDERBALL);
} else if (val == "Hot Picks") {
setValue(LottoStyle.HOTPICKS);
} else if (val == "Lotto Result") {
setValue(LottoStyle.LOTTORESULT);
} else {
setValue(LottoStyle.LOTTOLINE);
}

firePropertyChange();
}

public String getAsText() {
return value;
}
}

Can anyone please tell me what's going wrong???

   <<Less
About | Sitemap | Contact