Package vee

Source Code of vee.MainPanel

package vee;


import vee.animation.Animator;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.BoxLayout;
import javax.swing.JApplet;


import javax.swing.JFrame;

import javax.swing.JPanel;
import javax.swing.JTextField;
import vee.enemies.Henchwoman;


/**
* <p>A panel of this type encapsulates the contents of the top level
* window of this application. This includes the animator panel itself,
* a row of buttons for restarting, pausing and stepping the animation and
* a row of text boxes containing information about the seeding pattern to
* load at restart.</p>
*
* <p>Such a panel may either be used as the content pane of a
* {@link JFrame}, if our game is to run as an applications, or of a
* {@link JApplet}, if our game is to run as an applet.</p>
*
*
*/
@SuppressWarnings("serial")
public class MainPanel extends JPanel implements KeyListener {

  /*
   * Class variables and constants.
   */


  /*
   * Instance variables (fields)
   */
 

  /**
   * An animator panel. This is a graphics surface (panel) upon which
   * the game state is drawn. It also provides an animation loop which
   * ensures that the game state is updated and redrawn at regularly
   * spaced intervals.
   */
  private Animator mAnimator;
 
  private Player mPlayer;
 
  private Henchwoman mHenchwoman;

   
  /*
   * Constructor.
   */
 
  /**
   * Build a main panel, containing the animator panel,
   * control buttons and spinner input fields for the cell properties.
   */
  public MainPanel()  {
   
    /* allow the panel to be focused */
    this.setFocusable(true);
   
    /* request the component have default focus */
    this.requestFocusInWindow();
   
    mPlayer = new Player();
    mHenchwoman = new Henchwoman();

    setup();




  }

  /*
   * Methods
   */

 
  /**
   * Create the GUI components for this application
   * and lay them out on this panel.
   *
   */
  private void setup() {
    // build an animator for our automaton.
    mAnimator = new Animator(mHenchwoman);
//    mAnimator.addToAnimationList(mPlayer);

    setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));

    add(mAnimator);

  }

 
  /**
     * Access the animator object of this panel.
     *
   * @return the animator object aggregated into this object.
   */
  public Animator getAnimator() {
    return mAnimator;
  }
 
  public Player getPlayer() {
    return mPlayer;
  }
  public Henchwoman getHenchwoman() {
    return mHenchwoman;
  }

  @Override
  public void keyTyped(KeyEvent e) {
    System.out.println(e.getKeyChar());
  }

  @Override
  public void keyPressed(KeyEvent e) {
    System.out.println(e.getKeyChar());
  }

  @Override
  public void keyReleased(KeyEvent e) {
    System.out.println(e.getKeyChar());
  }

}
TOP

Related Classes of vee.MainPanel

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.