For example I can do something like:
switch (myString)
case "rectangle":
o = new rect();
break;
case "ellipse"
etc...
but how do I not do the above, i.e. just have one line of code that gets the object directly from the string. Imagine, for example, a button and whatever it says when the user clicks it, it takes the displayed text and creates an object from it.