I want to open a configuration screen and send back its data when user clicks ok.
I have these objects as configurations
configObjA a;
configObjB b;
Both implement IDisplayable (my interface).
Now the congfig screen gets two ArrayLists and put them in JLists gui.
it itterates the JList and put them in datamodel.
when I return from the screen , I want to send the main screen the results.
So I re-iterate the datamodel and put it all back in an arraylist
the problem is the main screen doesnt know anything about
Is there a way my configuration screen would return a type that the main screen will know?
I thought of returning
public List getOptionsList()
and in the method I wil create a list of the type I sent. (I would then have to keep the type i sent ). is that any good? how do i create a generic list when the type is of unknown
object type? any suggestion ?
btw: isnt my foolish gui process too complicated for that simple need?
You cannot. The whole point of generic lists is that you do know the object type at compile-time, so that the compiler can check your usage of that list.
If you know at least a parent class or interface (which is the usual case actually), you can use that:
If it can be any type of object, you can only say
which will accept any kind of Object, but removes the potential for meaningful compile-time type checking.