Package com.google.code.timetrail.gui

Source Code of com.google.code.timetrail.gui.StoreFrame

/*
* StoreFrame.java
* Team qq 2011
*/
package com.google.code.timetrail.gui;


import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import com.google.code.timetrail.backend.Control;
import com.google.code.timetrail.presenter.StoreFrameBackend;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;

public class StoreFrame extends JPanel implements DocumentListener{

    private static final long serialVersionUID = -7890141237462582071L;
    private JLabel ammunitionLabel;
    private JLabel clothingLabel;
    private JPanel storePanel;
    private JLabel foodLabel;
    private JLabel enginesLabel;
    private JLabel priceAndWeightLabel;
    private JLabel itemNameLabel;
    private JLabel quantityLabel;
    private JLabel storeLabel;
    private JLabel fCapacitorLabel;
    private JLabel hullPartsLabel;
    private JLabel fuelCellsLabel;
    private JLabel enginePriceWeightLabel;
    private JLabel foodPriceWeightLabel;
    private JLabel clothingPriceWeightLabel;
    private JLabel ammunitionPriceWeightLabel;
    private JLabel fCapacitorsPriceWeightLabel;
    private JLabel hullPartsPriceWeightLabel;
    private JLabel fuelCellsPriceWeightLabel;
    private JTextField engineTextField;
    private JTextField foodTextField;
    private JTextField clothingTextField;
    private JTextField ammunitionTextField;
    private JTextField fCapacitorTextField;
    private JTextField hullPartsTextField;
    private JTextField fuelCellsTextField;
    private JLabel totalWeightLabel;
    private JLabel totalCostLabel;
    private JLabel moneyLabel;
   
    private JButton storeNextButton;
    private JButton storeBackButton;
   
   
    private StoreFrameBackend storeBackend;
    private Control myGameControl;
    private JPanel myCD;
   
    public StoreFrame(Control gameControl, JPanel cd){
        this.myGameControl = gameControl;
        this.myCD = cd;
       
        storeBackend = new StoreFrameBackend(gameControl);
       
        storePanel = new JPanel();
       
        storeLabel = new JLabel(storeBackend.getStoreLabelText());
        storeLabel.setBounds(243, 11, 78, 14);
       
        quantityLabel = new JLabel(storeBackend.getQuantityLabelText());
        quantityLabel.setBounds(355, 53, 78, 14);
       
        itemNameLabel = new JLabel(storeBackend.getItemNameLabelText());
        itemNameLabel.setBounds(113, 53, 112, 14);
       
        priceAndWeightLabel = new JLabel(storeBackend.getPriceWeightLabelText());
        priceAndWeightLabel.setBounds(243, 53, 88, 14);
       
        enginesLabel = new JLabel(storeBackend.getEngineLabelText());
        enginesLabel.setBounds(113, 83, 112, 14);
       
        foodLabel = new JLabel(storeBackend.getFoodLabelText());
        foodLabel.setBounds(113, 109, 112, 14);
       
        clothingLabel = new JLabel(storeBackend.getClothingLabelText());
        clothingLabel.setBounds(113, 135, 112, 14);
       
        ammunitionLabel = new JLabel(storeBackend.getAmmunitionLabelText());
        ammunitionLabel.setBounds(113, 161, 112, 14);
       
        fCapacitorLabel = new JLabel(storeBackend.getFCapacitorLabelText());
        fCapacitorLabel.setBounds(113, 187, 112, 14);
       
        hullPartsLabel = new JLabel(storeBackend.getHullPartsLabelText());
        hullPartsLabel.setBounds(113, 213, 112, 14);
       
        fuelCellsLabel = new JLabel(storeBackend.getFuelCellsLabelText());
        fuelCellsLabel.setBounds(113, 238, 112, 14);
       
        enginePriceWeightLabel = new JLabel(storeBackend.getEnginePriceWeight());
        enginePriceWeightLabel.setBounds(243, 83, 88, 14);
       
        foodPriceWeightLabel = new JLabel(storeBackend.getFoodPriceWeight());
        foodPriceWeightLabel.setBounds(243, 109, 88, 14);
       
        clothingPriceWeightLabel = new JLabel(storeBackend.getClothingPriceWeight());
        clothingPriceWeightLabel.setBounds(243, 135, 88, 14);
       
        ammunitionPriceWeightLabel = new JLabel(storeBackend.getAmmunitionPriceWeight());
        ammunitionPriceWeightLabel.setBounds(243, 161, 88, 14);
       
        fCapacitorsPriceWeightLabel = new JLabel(storeBackend.getFCapacitorsPriceWeight());
        fCapacitorsPriceWeightLabel.setBounds(243, 187, 88, 14);
       
        hullPartsPriceWeightLabel = new JLabel(storeBackend.getHullPartsPriceWeight());
        hullPartsPriceWeightLabel.setBounds(243, 213, 88, 14);
       
        fuelCellsPriceWeightLabel = new JLabel(storeBackend.getFuelCellsPriceWeight());
        fuelCellsPriceWeightLabel.setBounds(243, 238, 88, 14);
       
        engineTextField = new JTextField();
        engineTextField.setBounds(355, 80, 54, 20);
        engineTextField.setHorizontalAlignment(SwingConstants.CENTER);
        engineTextField.setText("0");
        engineTextField.setColumns(10);
       
        foodTextField = new JTextField();
        foodTextField.setBounds(355, 106, 54, 20);

        foodTextField.setHorizontalAlignment(SwingConstants.CENTER);
        foodTextField.setText("0");
        foodTextField.setColumns(10);
       
        clothingTextField = new JTextField();
        clothingTextField.setBounds(355, 132, 54, 20);

        clothingTextField.setText("0");
        clothingTextField.setHorizontalAlignment(SwingConstants.CENTER);
        clothingTextField.setColumns(10);
       
        ammunitionTextField = new JTextField();
        ammunitionTextField.setBounds(355, 158, 54, 20);

        ammunitionTextField.setText("0");
        ammunitionTextField.setHorizontalAlignment(SwingConstants.CENTER);
        ammunitionTextField.setColumns(10);
       
        fCapacitorTextField = new JTextField();
        fCapacitorTextField.setBounds(355, 184, 54, 20);

        fCapacitorTextField.setText("0");
        fCapacitorTextField.setHorizontalAlignment(SwingConstants.CENTER);
        fCapacitorTextField.setColumns(10);
       
        hullPartsTextField = new JTextField();
        hullPartsTextField.setBounds(355, 210, 54, 20);

        hullPartsTextField.setText("0");
        hullPartsTextField.setHorizontalAlignment(SwingConstants.CENTER);
        hullPartsTextField.setColumns(10);
       
        fuelCellsTextField = new JTextField();
        fuelCellsTextField.setBounds(355, 235, 54, 20);

        fuelCellsTextField.setHorizontalAlignment(SwingConstants.CENTER);
        fuelCellsTextField.setText("0");
        fuelCellsTextField.setColumns(10);
       
        totalWeightLabel = new JLabel(storeBackend.getTotalWeightLabel());
        totalWeightLabel.setBounds(243, 277, 105, 14);
       
        totalCostLabel = new JLabel(storeBackend.getTotalCostLabel());
        totalCostLabel.setBounds(243, 303, 98, 14);
       
        moneyLabel = new JLabel(storeBackend.getMoneyLabel());
        moneyLabel.setBounds(113, 277, 99, 14);
       
        storeNextButton = new JButton(storeBackend.getNextButtonText());
        storeNextButton.setBounds(340, 328, 87, 23);
        storeNextButton.addActionListener(new ActionListener() {
           

            public void actionPerformed(ActionEvent e) {
               
               
               
               

               
                storeBackend.pressNextButton();
                myCD.add(new TakingMoveFrame(myGameControl, myCD, "Store"), "name_131784086749183704");
                CardLayout cd = (CardLayout) myCD.getLayout();
                cd.last(myCD);

            }
        });
       
        storeBackButton = new JButton(storeBackend.getBackButtonText());
        storeBackButton.setBounds(247, 328, 87, 23);
        storeBackButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                storeBackend.pressBackButton();
                CardLayout cd = (CardLayout) myCD.getLayout();
                cd.previous(myCD);
            }
        });
       
        engineTextField.getDocument().addDocumentListener(this);
        foodTextField.getDocument().addDocumentListener(this);
        clothingTextField.getDocument().addDocumentListener(this);
        ammunitionTextField.getDocument().addDocumentListener(this);
        fCapacitorTextField.getDocument().addDocumentListener(this);
        hullPartsTextField.getDocument().addDocumentListener(this);
        fuelCellsTextField.getDocument().addDocumentListener(this);
        GroupLayout groupLayout = new GroupLayout(this);
        groupLayout.setHorizontalGroup(
          groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup()
              .addContainerGap()
              .addComponent(storePanel, GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE)
              .addContainerGap())
        );
        groupLayout.setVerticalGroup(
          groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup()
              .addContainerGap()
              .addComponent(storePanel, GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
              .addContainerGap())
        );
        storePanel.setLayout(null);
        storePanel.add(storeBackButton);
        storePanel.add(storeNextButton);
        storePanel.add(storeLabel);
        storePanel.add(moneyLabel);
        storePanel.add(totalWeightLabel);
        storePanel.add(totalCostLabel);
        storePanel.add(itemNameLabel);
        storePanel.add(enginesLabel);
        storePanel.add(foodLabel);
        storePanel.add(clothingLabel);
        storePanel.add(ammunitionLabel);
        storePanel.add(fCapacitorLabel);
        storePanel.add(hullPartsLabel);
        storePanel.add(fuelCellsLabel);
        storePanel.add(priceAndWeightLabel);
        storePanel.add(enginePriceWeightLabel);
        storePanel.add(foodPriceWeightLabel);
        storePanel.add(clothingPriceWeightLabel);
        storePanel.add(ammunitionPriceWeightLabel);
        storePanel.add(fCapacitorsPriceWeightLabel);
        storePanel.add(hullPartsPriceWeightLabel);
        storePanel.add(fuelCellsPriceWeightLabel);
        storePanel.add(engineTextField);
        storePanel.add(foodTextField);
        storePanel.add(clothingTextField);
        storePanel.add(ammunitionTextField);
        storePanel.add(fCapacitorTextField);
        storePanel.add(hullPartsTextField);
        storePanel.add(fuelCellsTextField);
        storePanel.add(quantityLabel);
        setLayout(groupLayout);
    }

    @Override
    public void changedUpdate(DocumentEvent arg0) {
        // TODO Auto-generated method stub
       
    }

    @Override
    public void insertUpdate(DocumentEvent e) {

            storeBackend.setEngineTextField(engineTextField.getText());
            engineTextField.setBackground(storeBackend.getEngineTextFieldColor());
           
          

            storeBackend.setfoodTextField(foodTextField.getText());
            foodTextField.setBackground(storeBackend.getFoodTextFieldColor());
           
           

            storeBackend.setClothingTextField(clothingTextField.getText());
            clothingTextField.setBackground(storeBackend.getClothingTextFieldColor());

            storeBackend.setAmmunitionTextField(ammunitionTextField.getText());
            ammunitionTextField.setBackground(storeBackend.getAmmunitionTextFieldColor());

            storeBackend.setFCapacitorTextField(fCapacitorTextField.getText());
            fCapacitorTextField.setBackground(storeBackend.getFCapacitorTextFieldColor());

            storeBackend.setHullPartsTextField(hullPartsTextField.getText());
            hullPartsTextField.setBackground(storeBackend.getHullPartsTextFieldColor());

            storeBackend.setFuelCellsTextField(fuelCellsTextField.getText());
            fuelCellsTextField.setBackground(storeBackend.getFuelCellsTextFieldColor());

       
        engineTextField.setBackground(storeBackend.getEngineTextFieldColor());
        foodTextField.setBackground(storeBackend.getFoodTextFieldColor());
        clothingTextField.setBackground(storeBackend.getClothingTextFieldColor());
        ammunitionTextField.setBackground(storeBackend.getAmmunitionTextFieldColor());
        fCapacitorTextField.setBackground(storeBackend.getFCapacitorTextFieldColor());
        hullPartsTextField.setBackground(storeBackend.getHullPartsTextFieldColor());
        fuelCellsTextField.setBackground(storeBackend.getFuelCellsTextFieldColor());
       
        storeNextButton.setEnabled(storeBackend.canEnableNextButton());
        totalWeightLabel.setText(storeBackend.getTotalWeightLabel());
        totalCostLabel.setText(storeBackend.getTotalCostLabel());
    }
    @Override
    public void removeUpdate(DocumentEvent e) {


            storeBackend.setEngineTextField(engineTextField.getText());
            engineTextField.setBackground(storeBackend.getEngineTextFieldColor());
           
          

            storeBackend.setfoodTextField(foodTextField.getText());
            foodTextField.setBackground(storeBackend.getFoodTextFieldColor());
           

            storeBackend.setClothingTextField(clothingTextField.getText());
            clothingTextField.setBackground(storeBackend.getClothingTextFieldColor());

            storeBackend.setAmmunitionTextField(ammunitionTextField.getText());
            ammunitionTextField.setBackground(storeBackend.getAmmunitionTextFieldColor());

            storeBackend.setFCapacitorTextField(fCapacitorTextField.getText());
            fCapacitorTextField.setBackground(storeBackend.getFCapacitorTextFieldColor());

            storeBackend.setHullPartsTextField(hullPartsTextField.getText());
            hullPartsTextField.setBackground(storeBackend.getHullPartsTextFieldColor());

            storeBackend.setFuelCellsTextField(fuelCellsTextField.getText());
            fuelCellsTextField.setBackground(storeBackend.getFuelCellsTextFieldColor());

       
        engineTextField.setBackground(storeBackend.getEngineTextFieldColor());
        foodTextField.setBackground(storeBackend.getFoodTextFieldColor());
        clothingTextField.setBackground(storeBackend.getClothingTextFieldColor());
        ammunitionTextField.setBackground(storeBackend.getAmmunitionTextFieldColor());
        fCapacitorTextField.setBackground(storeBackend.getFCapacitorTextFieldColor());
        hullPartsTextField.setBackground(storeBackend.getHullPartsTextFieldColor());
        fuelCellsTextField.setBackground(storeBackend.getFuelCellsTextFieldColor());
       
        storeNextButton.setEnabled(storeBackend.canEnableNextButton());
        totalWeightLabel.setText(storeBackend.getTotalWeightLabel());
        totalCostLabel.setText(storeBackend.getTotalCostLabel());
    }
}
TOP

Related Classes of com.google.code.timetrail.gui.StoreFrame

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.