私はこの機能を持っています:
/***
* 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());
}
これはCBPanel唯一の引数として取りCBPanel、通常は に実装されるインターフェイスですJCOmponent。JComponentfrom インターフェイス クラスのインスタンスを取得する方法はありますか?
私はそう呼んでいます
changePanel(new LoginPanel());
論理的には、 のインスタンスを取得できるはずLoginPanelですよね? ある種の型キャストの型宣言を使用するかどうか疑問に思っていましたか?