package xyz.danielcortes.views;

import java.awt.CardLayout;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import xyz.danielcortes.framework.PanelName;

public class LaunchFrame extends JFrame {

  public LaunchFrame() {
    this.setSize(800, 600);
    this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    this.setLocationRelativeTo(null);
    this.setupCardPanel();
  }

  private void setupCardPanel() {
    JPanel cards = new JPanel();
    cards.setLayout(new CardLayout());
    this.setContentPane(cards);
  }

  public void addCard(JComponent component, PanelName name) {
    this.getContentPane().add(component, name.name());
  }

  public void showCard(PanelName name) {
    CardLayout layout = (CardLayout) this.getContentPane().getLayout();
    layout.show(this.getContentPane(), name.name());
  }
}
