i building gui's input dynamically based on type of input required, example:
if require doubleand boolean type of components gui creates jtextfield , jradiobutton.
i define want each type's input method statically so:
private static map<inputtype, class<? extends component>> typecomponentmap = new hashmap<inputtype, class<? extends component>>(); static { typecomponentmap.put(inputtype.integer, jtextfield.class); typecomponentmap.put(inputtype.double, jtextfield.class); typecomponentmap.put(inputtype.boolean, jradiobutton.class); typecomponentmap.put(inputtype.string, jtextfield.class); } i facing problem when trying read value of component 1 of types (into stream)
my method looks this:
public static void writecomponentvalue(objectoutputstream stream, inputtype type, component component) now there's no method getvalue in java.awt.component, can see 1 option check subclass using instanceof , go there... hoping there's better way?
the created stream intended passed object intended not know how information gui.
you can implement interface requires getinput method , make subclasses of jcomponents implement interface.
Comments
Post a Comment