So I have an object that holds a nonspecific JPanel:
private static JPanel setPanel;
I have lots of JPanel subclasses for different kinds of screens I'm swapping out on my JFrame, which behave differently. Now, each of these subclasses implements a certain method getKeyPress()
, and I have made an interface that includes this method, which every one of these JPanel subclasses also implements. My question is whether I can refer to that method through my generic setPanel object, as in: setPanel.getKeyPress()
in some convenient manner, or do I have to create a subclass of JPanel with that one method in it and then have each subclass be a subclass of that one?