の任意のパネルの「コンテナ」パネルを取得する方法CardLayout
。
つまり、パネルが別の「コンテナ」パネルのカードである場合、カードからこの「コンテナ」パネルへの参照を取得するにはどうすればよいですか?
これが私がしていることです:-
public class LogInPanel extends javax.swing.JPanel implements ActionListener{
/**
* Creates new form Panel2
*/
private JPanel parentPanel;
private CardLayout c1=null;
public LogInPanel() {
initComponents();
//c1=new CardLayout();
parentPanel=(JPanel)(SwingUtilities.getAncestorOfClass(this.getClass(), this));
c1=(CardLayout)(parentPanel.getLayout());
submitLogin.addActionListener(this);
}
...