Package view

Source Code of view.main_window

package view;

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import custom_swing.JBGPanel;
import data_model.card;
import data_model.gambler;

public class main_window extends JFrame {

  /**
   *
   */
  private static final long serialVersionUID = 1L;

  static gambler selected_gambler;

  // static player_choose_main playerchoose = new player_choose_main();
  static main_menu mainmenu = new main_menu();
  static deck_builder deckbuilder = new deck_builder();
  static game_panel game = new game_panel(); // weitere
  // Panels
  // f�r
  // Shop,
  // Deckaufbau, Hauptmen�,
  // (Spielfeld) ...

  static JPanel card = new JPanel(new CardLayout());
  static CardLayout cl = (CardLayout) (card.getLayout());

  JBGPanel cp = new JBGPanel("./src/img/MainBG.jpg");

  static public Font getFont(float size) {
    Font font = null;
    try {
      font = Font.createFont(Font.TRUETYPE_FONT, new File(
          "./src/font/Northwood High.ttf"));
      font = font.deriveFont(size);
    } catch (FontFormatException ex) {
      Logger.getLogger(game_menu_panel.class.getName()).log(Level.SEVERE,
          null, ex);
    } catch (IOException ex) {
      Logger.getLogger(game_menu_panel.class.getName()).log(Level.SEVERE,
          null, ex);
    }
    return font;
  }

  public static gambler getSelected_gambler() {
    return selected_gambler;
  }

  public static void setSelected_gambler(gambler selectedGambler) {
    selected_gambler = selectedGambler;
    mainmenu.setName(selected_gambler.getName());
    showCard("Menu");
  }

  public static void showCard(String s) {
    cl.show(card, s);
  }

  // Hauptfenster erstellen in dem die jeweils notwendigen Panels geladen
  // werden (Spielfeld, Deckaufbau ...)
  public main_window() {
    // +++++++++++++++Testdaten+++++++++++++//
    ArrayList<card> test_deck = new ArrayList<card>();

    card c1 = new card(0, 1, 1, 1, 7, 1, 100, "TestA",
        "./src/img/TestKarte.png", true);
    card c2 = new card(0, 2, 6, 1, 1, 1, 100, "TestB",
        "./src/img/TestKarte.png", true);
    card c3 = new card(0, 3, 1, 1, 5, 1, 100, "TestC",
        "./src/img/TestKarte.png", true);
    card c4 = new card(0, 4, 4, 1, 1, 6, 100, "TestD",
        "./src/img/TestKarte.png", true);
    card c5 = new card(0, 5, 1, 3, 3, 1, 100, "TestE",
        "./src/img/TestKarte.png", true);
    card c6 = new card(0, 6, 1, 1, 1, 7, 100, "TestF",
        "./src/img/TestKarte.png", true);
    card c7 = new card(0, 7, 1, 4, 1, 1, 100, "TestG",
        "./src/img/TestKarte.png", true);
    card c8 = new card(0, 8, 1, 3, 9, 4, 100, "TestH",
        "./src/img/TestKarte.png", true);

    test_deck.add(c1);
    test_deck.add(c2);
    test_deck.add(c3);
    test_deck.add(c4);
    test_deck.add(c5);
    test_deck.add(c6);
    test_deck.add(c7);
    test_deck.add(c8);

    gambler p1 = new gambler(1, "Hans Ahlewurst", 1000, 1, test_deck,
        test_deck, Color.red);
    gambler p2 = new gambler(2, "Horst Immenau", 1500, 2, test_deck,
        test_deck, Color.cyan);
    // +++++++++++++++++++++++++++++++++++++//
    // Spielfeld_Model sp = new Spielfeld_Model(p1,p2);
    // game_panel.setGame(sp);
    this.setContentPane(cp);
    cp.setCenter(card);
    // card.add(playerchoose,"Player");
    card.add(mainmenu, "Menu");
    card.add(deckbuilder, "Deck");
    card.add(game, "Game");
    card.setOpaque(false);
    cl.show(card, "Game");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(1100, 700);// Gr��e anpassbar -> Komponenten sollen unter
    // Beibehaltung des Seitenverh�ltnisses
    // angepasst werden
    this.setVisible(true);
  }
}
TOP

Related Classes of view.main_window

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.