I have created a Class (Class 1). And from that Class, I created 3 other Subclasses (Subclasses 1,2, and 3). Now, I have a Vector of type Class 1. Each subclass has a specific field that is know as its "selected item", as in it it the currently display selection on the screen. (It would be from a JCheckBox, JSpinner, or JComboBox.) Is there a way to create a Method in Class 1 that can access those fields depending on the "type" that it is? the Name and Type are common and accessible from the Class 1.
I add a Subclass 1 item to the Vector.
I add a Subclass 3 item to the Vector.
Now I need to know the currently selected item of element 1 in the Vector.
Is this possible?
Sounds like you have been given an assignment on Polymorphism. You may find this example useful.
this uses an array but the same concept applies.