projekt  
  einleitung
  applet
  quellcode
über  
  info
  team
quellcode
 
JAVADOC
SOURCECODE
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class ControlPanel extends JPanel
{
  /*
  private Icon yawLeftI = new ImageIcon(getToolkit().createImage("yawLeft.gif"));
  private Icon yawRightI = new ImageIcon(getToolkit().createImage("yawRight.gif"));
  private Icon BoosterI = new ImageIcon(getToolkit().createImage("Booster.gif"));
  private Icon RetroI = new ImageIcon(getToolkit().createImage("Retro.gif"));
  */

  //private static JButton yawLeft = new JButton("yaw left", new ImageIcon("yawLeft.gif"));
  private static JButton yawLeft = new JButton("<");
  private static JButton yawRight = new JButton(">");
  private static JButton Booster = new JButton("BOOST");
  private static JButton Retro = new JButton("RETRO");

  private static Image heading;

  static
  {
    //add listeners
    yawLeft.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
	    Mass m=(Mass)Physics.masses.get(MassPanel.getActiveMass());
        if(m instanceof Craft)
        {
		if(((Craft)m).yawL==false)
		{
		  ((Craft)m).yawR=false;
		  ((Craft)m).yawL=true;
		}
		else
		{
		  ((Craft)m).yawL=false;
		}
		}
		update();
      } });
    yawRight.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
	    Mass m=(Mass)Physics.masses.get(MassPanel.getActiveMass());
        if(m instanceof Craft)
        {	
	    if(((Craft)m).yawR==false)
		{
		  ((Craft)m).yawL=false;
		  ((Craft)m).yawR=true;
		}
		else
		{
		  ((Craft)m).yawR=false;
		}
		}
		update();
      } });
    Booster.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
	    Mass m=(Mass)Physics.masses.get(MassPanel.getActiveMass());
        if(m instanceof Craft)
        {	
	    if(((Craft)m).boost==false)
		{
		  ((Craft)m).boost=true;
		}
		else
		{
		  ((Craft)m).boost=false;
		}
		}
		update();
      } });
    Retro.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
	    Mass m=(Mass)Physics.masses.get(MassPanel.getActiveMass());
        if(m instanceof Craft)
        {	
	    if(((Craft)m).retro==false)
		{
		  ((Craft)m).retro=true;
		}
		else
		{
		  ((Craft)m).retro=false;
		}
		}
		update();
      } });	  	  	
  }

  ControlPanel()
  {
    //do layout
    this.setBorder(BorderFactory.createTitledBorder("Control"));
    setLayout(new BorderLayout());
    JPanel contentPanel= new JPanel(new GridLayout(1,2));
    contentPanel.setBackground(new Color(128,128,75));
    yawLeft.setBackground(Color.white);
    yawRight.setBackground(Color.white);
    Booster.setBackground(Color.white);
    Retro.setBackground(Color.white);
    JPanel steeringPanel= new JPanel(new BorderLayout());
    steeringPanel.add(yawLeft, BorderLayout.WEST);
    steeringPanel.add(yawRight, BorderLayout.EAST);
    steeringPanel.add(Booster, BorderLayout.NORTH);
    steeringPanel.add(Retro, BorderLayout.SOUTH);
    contentPanel.add(steeringPanel);
    add(contentPanel, BorderLayout.NORTH);
  }

  //update button-colors
  public static void update()
  {
     int i=MassPanel.getActiveMass();
     if(i!=-1)
     {
       Mass m=(Mass)Physics.masses.get(i);
       if(m instanceof Craft)
       {
         if (((Craft)m).yawL==true) yawLeft.setBackground(Color.yellow);
         if (((Craft)m).yawR==true) yawRight.setBackground(Color.yellow);
         if (((Craft)m).boost==true) Booster.setBackground(Color.red);
         if (((Craft)m).retro==true) Retro.setBackground(Color.orange);
         if (((Craft)m).yawL==false) yawLeft.setBackground(Color.white);
         if (((Craft)m).yawR==false) yawRight.setBackground(Color.white);
         if (((Craft)m).boost==false) Booster.setBackground(Color.white);
         if (((Craft)m).retro==false) Retro.setBackground(Color.white);
       }
       if(m instanceof Craft == false)
       {
         yawLeft.setBackground(Color.white);
         yawRight.setBackground(Color.white);
         Booster.setBackground(Color.white);
         Retro.setBackground(Color.white);
       }
     }
     else
     {
       yawLeft.setBackground(Color.white);
       yawRight.setBackground(Color.white);
       Booster.setBackground(Color.white);
       Retro.setBackground(Color.white);
     }
  }


}