After searching SO and the web, I've yet to come up with an answer for this in Java. It's pretty simple.
I've got abstract class ParentClass. Class X and class Y both inherit from ParentClass. I've also got class DataInputDialog extends JDialog, which is meant to provide a user interface for entering data into class X and class Y instances. DataInputDialog class looks like below:
public class DataInputDialog extends JDialog {
    public DataInputDialog(ParentClass xOrY) {
        //calls super constructor, makes basic components such as
        //  buttons and panels that are used in either X or Y data entry
    }
}
now I'd like to have a switch statement that would determine what type of ParentClass was passed to DataInputDialog. However, I've got no clue how to accomplish that. I've tried:
switch (xOrY.getClass().getTypeName()) {
    case X.class.getTypeName();
}
and a couple other variations, but it always comes up with an error on the case statement saying either: it has to be a constant String, or that it cannot be converted to an integer.
How do I get this switch statement to determine if xOrY is an instance of X or Y?
 
     
     
    