Can I get an instance of a class that implements an interface?
I have this function:
/***
* Changes the windows panel and allows a state change
* you can also change the minimum window size
* */
public void changePanel(CBPanel panel){
mainFrame.setContentPane();
mainFrame.setMinimumSize(panel.getMinSize());
mainFrame.setResizable(panel.canResize());
}
It takes CBPanel as the only argument and CBPanel is interface that
generally will be implemented onto a JCOmponent. Is there any way I can
get an instance of the JComponent from interface class?
I call it like so
changePanel(new LoginPanel());
So logically, I should be able to get an instance of the LoginPanel,
right? I was wondering if it does using some kind of type declaration of
type cast?
No comments:
Post a Comment