Results 1 to 10 of 10
  1. #1
    Rekuta is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default Problem of conversion JFrame to Applet

    Hi everybody , I have a problem : I don't know how to convert my JFrame program into an applet. I am creating a game and instead of compiling and printing it out on the console, i would like to use it on an applet instead. the code is pretty long and unfinished, so here goes:

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.JFrame;
    import java.awt.GridLayout;
    import java.io.*;
    import java.util.Scanner;
    import java.applet.Applet;
    import java.awt.TextArea;
    
    class Player 
    {
    	  int LifePoints = 120;
    	  int Experience = 0;
    	  int ATKPoints = 20;
    	  int Attack = 0;
    	  int DFPoints = 20;
    	  int Defense = 0;
    	  int Level = 1;
    	  int Niveau = 1;
          int LevelLocation = 1;
          int LeftRightLocation = 3;
          int UpDownLocation = 2;
    }
    class Monster
    {
    	 int DeathPoints;
    	 int PowerLevel;
    	 int ForcePoints;
    	 int ArmorPoints;
    	 int location;
         int LevelLocation;
         int LeftRightLocation;
         int UpDownLocation;
         int MonsterAttack = 0;
    }	
    
    
    class RPG13 extends Applet {
    	
    	public void init() {
    	}
    
    	public void paint(Graphics g) {
    		
    		g.drawString("Welcome to Java!!", 50, 60 );
    		
    	}
    } 
    public class RPG12 extends JFrame 
    {
    	public static int QuitGame = 0;
    	public static int NewGame = 0;
    	public static int Options = 0;
    	public static int Credits = 0;
    	public static int MainMenu = 0;
    	
    	private KeyboardPanel keyboardPanel = new KeyboardPanel();
    	private ImageIcon GameIcon = new ImageIcon("f:/School Programmation/Dungeons of Darkness.gif");
        	 
    	public RPG12()
    	{
    		setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
    		add(keyboardPanel);
    		
    	    keyboardPanel.setFocusable(true);
          
          
           add(new JLabel(GameIcon));
           repaint();
    	} 
    	
     
    
        public static void main(String[] args)
        {  
        	Player Player1 = new Player();
        	Monster Wolf1 = new Monster();
        	Monster Wolf2 = new Monster();
        	Monster Wolf3 = new Monster();
        	Monster Wolf4 = new Monster();
        	Monster Snake1 = new Monster();
        	Monster Snake2 = new Monster();
        	Monster Snake3 = new Monster();
        	Monster Snake4 = new Monster();
        	Monster Snake5 = new Monster();
        	Monster Snake6 = new Monster();
        	Monster Eagle1 = new Monster();
        	Monster Eagle2 = new Monster();
        	Monster Eagle3 = new Monster();
        	Monster Eagle4 = new Monster();
        	Monster Eagle5 = new Monster();
        	Player1.LeftRightLocation = 2;
        	Player1.UpDownLocation = 2;
        	Snake1.LeftRightLocation = 19;
            Snake1.UpDownLocation = 4;
            Eagle1.LeftRightLocation = 66;  
            Eagle1.UpDownLocation = 4;
            Wolf1.LeftRightLocation = 64;
            Wolf1.UpDownLocation = 21;
            Snake2.LeftRightLocation = 59;
            Snake2.UpDownLocation = 4;
            Eagle2.LeftRightLocation = 112; 
            Eagle2.UpDownLocation = 12;
            Wolf2.LeftRightLocation = 108;
            Wolf2.UpDownLocation = 	31;
            Snake3.LeftRightLocation = 95;
            Snake3.UpDownLocation = 12;
            Eagle3.LeftRightLocation = 25; 
            Eagle3.UpDownLocation = 22;
            Snake3.LeftRightLocation = 93;
            Snake3.UpDownLocation = 15;
            Eagle4.LeftRightLocation = 57; 
            Eagle4.UpDownLocation = 25;
            Wolf3.LeftRightLocation = 94;
            Wolf3.UpDownLocation = 33;
            Snake4.LeftRightLocation = 40;
            Snake4.UpDownLocation = 22;
            Wolf4.LeftRightLocation = 106;
            Wolf4.UpDownLocation = 38;
            Snake5.LeftRightLocation = 73;
            Snake5.UpDownLocation = 25;
            Eagle5.LeftRightLocation = 101; 
            Eagle5.UpDownLocation = 34;
            Snake6.LeftRightLocation = 113;
            Snake6.UpDownLocation = 16;
            Snake1.DeathPoints = 20;
            Snake1.ArmorPoints = 5;
            Snake1.ForcePoints = 10;
            Snake1.PowerLevel = 1;
            Snake2.DeathPoints = 20;
            Snake2.ArmorPoints = 5;
            Snake2.ForcePoints = 10;
            Snake2.PowerLevel = 1;
            Snake3.DeathPoints = 20;
            Snake3.ArmorPoints = 5;
            Snake3.ForcePoints = 10;
            Snake3.PowerLevel = 1;
            Snake4.DeathPoints = 20;
            Snake4.ArmorPoints = 5;
            Snake4.ForcePoints = 10;
            Snake4.PowerLevel = 1;
            Snake5.DeathPoints = 20;
            Snake5.ArmorPoints = 5;
            Snake5.ForcePoints = 10;
            Snake5.PowerLevel = 1;
            Snake6.DeathPoints = 25;
            Snake6.ArmorPoints = 5;
            Snake6.ForcePoints = 10;
            Snake6.PowerLevel = 2;
            Eagle1.DeathPoints = 40;
            Eagle1.ArmorPoints = 10;
            Eagle1.ForcePoints = 15;
            Eagle1.PowerLevel = 2;
            Eagle2.DeathPoints = 40;
            Eagle2.ArmorPoints = 10;
            Eagle2.ForcePoints = 15;
            Eagle1.PowerLevel = 3;
            Eagle3.DeathPoints = 40;
            Eagle3.ArmorPoints = 10;
            Eagle3.ForcePoints = 15;
            Eagle1.PowerLevel = 3;
            Eagle4.DeathPoints = 40;
            Eagle4.ArmorPoints = 10;
            Eagle4.ForcePoints = 15;
            Eagle4.PowerLevel = 3;
            Eagle5.DeathPoints = 50;
            Eagle5.ArmorPoints = 10;
            Eagle5.ForcePoints = 15;
            Eagle5.PowerLevel = 4;
            Wolf1.DeathPoints = 60;
            Wolf1.ArmorPoints = 15;
            Wolf1.ForcePoints = 30;
            Wolf1.PowerLevel = 4;
            Wolf2.DeathPoints = 60;
            Wolf2.ArmorPoints = 15;
            Wolf2.ForcePoints = 30;
            Wolf2.PowerLevel = 4;
            Wolf3.DeathPoints = 60;
            Wolf3.ArmorPoints = 15;
            Wolf3.ForcePoints = 30;
            Wolf3.PowerLevel = 4;
            Wolf4.DeathPoints = 70;
            Wolf4.ArmorPoints = 15;
            Wolf4.ForcePoints = 30;
            Wolf4.PowerLevel = 5;
           					
       	    Monster Edimo2 = new Monster();
        	Monster Ogre3 = new Monster();
       	    Monster Kalaba2 = new Monster();
       	    Monster Demon5 = new Monster();
       	    Monster Dragon5 = new Monster();
       	    Monster Troll2 = new Monster();
       	    Monster Spider5 = new Monster();
       	    Monster Gengueoo3 = new Monster();
       	    Monster Moukandjo4 = new Monster();
       	    Monster Geleri4 = new Monster();
       	    Monster Nkouam3 = new Monster();
       	    Monster Gevaudan5 = new Monster();
        	
        	int Gamerun = 0;
        	 Scanner in = new Scanner(System.in);
        	 
        	 int levelarea = 0;
        	int i, j, a, b;
        	char[][] levelx; 
        	char[][] Levela;
        	 char[] temp;
        	 
        	 
        	 levelx = new char[3000][3000];
            Levela = new char[3000][3000];
        	String level[];
        	FileInputStream fin;
        	 
        	 level = new String [50];
            
             String MoveSet;
           
            
        	try
        	{
        		fin = new FileInputStream ("f:/School Programmation/Niveau 1X.txt");
      
        	 for(  i = 0; i < 44; i++)
        	 {
        	   level[i] = new DataInputStream(fin).readLine() ;
         
        	  
        	   for (j = 0; j < 122; j++)
        	   {
        	   	levelx[i][j] = level[i].charAt(j);
        		
        	   }
         
        	  
        	  }
        	 	  	
        		fin.close();
        	}
        	
        	catch (IOException e)
        	{
        		System.err.println("Unable to read from file");
        		System.exit(-1);
        	}	
        		
        		
        	
        	RPG12 frame = new RPG12();
        	frame.setTitle("Dungueons Of Darkness");
        	frame.setLocationRelativeTo(null);
        	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        	frame.setSize(1024, 768);
        	frame.setVisible(true);
            frame.setLocation(0,0);
           	  	  	  
        	
        	RPG12 frame2 = new RPG12();
        	frame2.setTitle("Options");
        	frame2.setLocationRelativeTo(null);
        	frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        	frame2.setSize(1024, 768);
        	frame2.setVisible(false);
        	frame2.setLocation(0,0);
        	
        	RPG12 frame3 = new RPG12();
        	frame3.setTitle("Credits");
        	frame3.setLocationRelativeTo(null);
        	frame3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        	frame3.setSize(1024, 768);
        	frame3.setVisible(false);
        	frame3.setLocation(0,0);
        	
        	
        	while (MainMenu < 100)
        	{
        		
        		if (MainMenu == 1)
        		{
        			frame.setVisible(true);
        			frame2.setVisible(false);
        			frame3.setVisible(false);
        			MainMenu = 0;
        			
        		}	
        	
        		
        	 
        		if (NewGame == 1)
        		{ 
        		 Gamerun = 1;
        		 frame.setVisible(false);
        		 
        		 
        			 for(i = 0; i < 44; i++)
        	           {
        	           
        	           for (j = 0; j < 122; j++)
        	           {
        	   	         Levela[i][j] = levelx[i][j];
        	             }
        		        }
        		   levelarea = 1;
        		   NewGame = 0;
        	 
        		}
        		
        		
        
        		
       // copy level from origional level to temporary area 		
        		
        		
        		if (levelarea == 1)
        		{
        			 for(i = 0; i < 44; i++)
        	           {
        	           
        	           for (j = 0; j < 122; j++)
        	           {
        	   	         Levela[i][j] = levelx[i][j];
        	            
        	             }
        	          
        		        }
        		}
        		
        	// putting character on temporary level
        		
        	     if (Player1.LifePoints > 0)	
        		Levela[Player1.UpDownLocation][Player1.LeftRightLocation] = 'P';
        	     if(Wolf1.DeathPoints > 0)		
        	    Levela[Wolf1.UpDownLocation][Wolf1.LeftRightLocation] = 'W';
        	     if(Wolf2.DeathPoints > 0)	
        	    Levela[Wolf2.UpDownLocation][Wolf2.LeftRightLocation] = 'W';
        	     if(Wolf3.DeathPoints > 0)	
        	    Levela[Wolf3.UpDownLocation][Wolf3.LeftRightLocation] = 'W';
        	     if(Wolf4.DeathPoints > 0)	
        	    Levela[Wolf4.UpDownLocation][Wolf4.LeftRightLocation] = 'W';
                 if(Snake1.DeathPoints > 0) 	
        	    Levela[Snake1.UpDownLocation][Snake1.LeftRightLocation] = 'S';
                 if(Snake2.DeathPoints > 0)
        	    Levela[Snake2.UpDownLocation][Snake2.LeftRightLocation] = 'S';
        	     if(Snake3.DeathPoints > 0)   
        	    Levela[Snake3.UpDownLocation][Snake3.LeftRightLocation] = 'S';
        	     if(Snake4.DeathPoints > 0) 
        	    Levela[Snake4.UpDownLocation][Snake4.LeftRightLocation] = 'S';
        	     if(Snake5.DeathPoints > 0) 
        	    Levela[Snake5.UpDownLocation][Snake5.LeftRightLocation] = 'S';
        	     if(Snake6.DeathPoints > 0)
        	    Levela[Snake6.UpDownLocation][Snake6.LeftRightLocation] = 'S';
        	     if(Eagle1.DeathPoints > 0)
        	    Levela[Eagle1.UpDownLocation][Eagle1.LeftRightLocation] = 'E';
        	     if(Eagle2.DeathPoints > 0)
        	    Levela[Eagle2.UpDownLocation][Eagle2.LeftRightLocation] = 'E';
        	     if(Eagle3.DeathPoints > 0)
        	    Levela[Eagle3.UpDownLocation][Eagle3.LeftRightLocation] = 'E';
        	     if(Eagle4.DeathPoints > 0)
        	    Levela[Eagle4.UpDownLocation][Eagle4.LeftRightLocation] = 'E';
        	     if(Eagle5.DeathPoints > 0)
        	    Levela[Eagle5.UpDownLocation][Eagle5.LeftRightLocation] = 'E';
        	
        	// printing screen out
        	    	
        
        	
        		if (levelarea == 1)
        		{
        			 for(i = 0; i < 44; i++)
        	           {
        	        
        	           for (j = 0; j < 122; j++)
        	           {
        	           
        	             System.out.print(Levela[i][j]);
        	             }
        	            System.out.println("");
        		        }
        		        
        		    	System.out.print(" LifePoints = " + Player1.LifePoints);
        		    	System.out.print(" Experience =  " + Player1.Experience);
        		    	System.out.print(" Level =  " + Player1.Level);
        		    	System.out.print(" ATKPoints =  " + Player1.ATKPoints);   
        		       	System.out.print(" DFPoints =  " + Player1.DFPoints);
        		       	
        		 
        		       	
        		      	if (Math.abs(Player1.LeftRightLocation - Snake1.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Snake1.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Snake1.PowerLevel);	
        		       	System.out.print(" DeathPoints =  " + Snake1.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Snake1.ForcePoints);   
        		       	System.out.print("ArmorPoints =  " + Snake1.ArmorPoints);
        		       	
        		       	 
        		       	 Snake1.MonsterAttack = 1; 
        		       	}
        		        
        		        if(Math.abs(Player1.LeftRightLocation - Snake1.LeftRightLocation) < 2 && Math.abs(Player1.UpDownLocation - Snake1.UpDownLocation) < 2)
        		        {
        		          System.out.println("LifePoints = " + Player1.LifePoints);
        		          System.out.println("DeathPoints = " + Snake1.DeathPoints);
        		          
        		        }	
        		       	 
        		       	 if (Math.abs(Player1.LeftRightLocation - Snake2.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Snake2.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Snake2.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Snake2.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Snake2.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Snake2.ArmorPoints);
        		       	
        		       	 Snake2.MonsterAttack = 1; 
        		       	}
        		       	 
        		       	 if (Math.abs(Player1.LeftRightLocation - Snake3.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Snake3.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Snake3.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Snake3.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Snake3.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Snake3.ArmorPoints);
        		       	
        		       	 Snake3.MonsterAttack = 1; 
        		       	}
        		       	 
        		       	 if (Math.abs(Player1.LeftRightLocation - Snake4.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Snake4.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Snake4.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Snake4.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Snake4.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Snake4.ArmorPoints);
        		       	
        		       	 Snake4.MonsterAttack = 1; 
        		       	}
        		       	 
        		       	 
        		       	 if (Math.abs(Player1.LeftRightLocation - Snake5.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Snake5.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Snake5.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Snake5.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Snake5.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Snake5.ArmorPoints);
        		       	
        		       	 Snake5.MonsterAttack = 1; 
        		       	}
        		       	 
        		       	 
        		       	if (Math.abs(Player1.LeftRightLocation - Snake6.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Snake6.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Snake6.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Snake6.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Snake6.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Snake6.ArmorPoints);
        		       	
        		       	 Snake6.MonsterAttack = 1; 
        		       	} 
        		       	
        		       	 if (Math.abs(Player1.LeftRightLocation - Eagle1.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Eagle1.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Eagle1.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Eagle1.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Eagle1.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Eagle1.ArmorPoints);
        		       	
        		       	 Eagle1.MonsterAttack = 1; 
        		       	}
        		       	 
        		       	  if (Math.abs(Player1.LeftRightLocation - Eagle2.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Eagle2.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Eagle2.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Eagle2.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Eagle2.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Eagle2.ArmorPoints);
        		       	
        		       	 Eagle2.MonsterAttack = 1; 
        		       	}
        		       	 
        		       	 if (Math.abs(Player1.LeftRightLocation - Eagle3.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Eagle3.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Eagle3.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Eagle3.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Eagle3.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Eagle3.ArmorPoints);
        		       	
        		       	 Eagle3.MonsterAttack = 1; 
        		       	} 
        		       	 
        		       	 
        		       	 if (Math.abs(Player1.LeftRightLocation - Eagle4.LeftRightLocation) < 3 && Math.abs(Player1.UpDownLocation - Eagle4.UpDownLocation) < 3)
        		       	{
        		       	System.out.println(" PowerLevel = " + Eagle4.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Eagle4.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Eagle4.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Eagle4.ArmorPoints);
        		       	 
        		       	 Eagle4.MonsterAttack = 1;
        		       	} 
        		      
        		       
        		       	 
        		       	  if (Math.abs(Player1.LeftRightLocation - Eagle5.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Eagle5.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Eagle5.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Eagle5.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Eagle5.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Eagle5.ArmorPoints);
        		       	
        		       	 Eagle5.MonsterAttack = 1; 
        		       	}
        		       	 
        		       	  if (Math.abs(Player1.LeftRightLocation - Wolf1.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Wolf1.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Wolf1.PowerLevel);	
        		       	System.out.println(" DeathPoints =  " + Wolf1.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Wolf1.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Wolf1.ArmorPoints);
        		       	
        		       	 Wolf1.MonsterAttack = 1; 
        		       	}
        		       	 
        		       	 
        		       	  if (Math.abs(Player1.LeftRightLocation - Wolf2.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Wolf2.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Wolf2.PowerLevel);		
        		       	System.out.println(" DeathPoints =  " + Wolf2.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Wolf2.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Wolf2.ArmorPoints);
        		       	
        		       	 Wolf2.MonsterAttack = 1; 
        		       	} 
        		       	 
        		       	  
        		       	  if (Math.abs(Player1.LeftRightLocation - Wolf3.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Wolf3.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Wolf3.PowerLevel);			
        		       	System.out.println(" DeathPoints =  " + Wolf3.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Wolf3.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Wolf3.ArmorPoints);
        		       	
        		       	 Wolf3.MonsterAttack = 1; 
        		       	}
        		       	
        		       	 
        		       	  if (Math.abs(Player1.LeftRightLocation - Wolf4.LeftRightLocation) < 5 && Math.abs(Player1.UpDownLocation - Wolf4.UpDownLocation) < 4)
        		       	{
        		       	System.out.println(" PowerLevel = " + Wolf4.PowerLevel);			
        		       	System.out.println(" DeathPoints =  " + Wolf4.DeathPoints);
        		    	System.out.print(" ForcePoints =  " + Wolf4.ForcePoints);   
        		       	System.out.print(" ArmorPoints =  " + Wolf4.ArmorPoints);
        		       	
        		       	 Wolf4.MonsterAttack = 1; 
        		       	}
        		       	
        		       	
        		       	 	
        		}
        	
      
        	    
        	  if (Gamerun == 1)
        	  {
        	  	 // Reads a single line from the console 
           // and stores into name variable
           MoveSet = in.nextLine();
    
           System.out.println("You typed : " + MoveSet);
           
             if (Levela[Player1.UpDownLocation][Player1.LeftRightLocation  + 1] != '|' ) 
             if (Levela[Player1.UpDownLocation][Player1.LeftRightLocation  + 1] != '_' )	
             if (Levela[Player1.UpDownLocation][Player1.LeftRightLocation  + 1] != 'S' ) 
             if (Levela[Player1.UpDownLocation][Player1.LeftRightLocation  + 1] != 'E' ) 
             if (Levela[Player1.UpDownLocation][Player1.LeftRightLocation  + 1] != 'W' )
             {
             
               if (MoveSet.indexOf('r') == 0)
                {
                Player1.LeftRightLocation += 1;	
                }
      
              }
        	  
        	  if (Levela[Player1.UpDownLocation][Player1.LeftRightLocation + 1] != '_' )
             {
             
               if (MoveSet.indexOf('d') == 0)
                {
                Player1.UpDownLocation += 1;	
                }
               
              }	
        	  if (Levela[Player1.UpDownLocation][Player1.LeftRightLocation - 1] != '|' )
             {
             
               if (MoveSet.indexOf('l') == 0)
                {
                Player1.LeftRightLocation -= 1;	
                }
      
              }	
        	  
        	    if (Levela[Player1.UpDownLocation - 1 ][Player1.LeftRightLocation] != '_' )
               {
             
               if (MoveSet.indexOf('u') == 0)
                {
                Player1.UpDownLocation -= 1;	
                }
                
               }
        	    
        	    if (MoveSet.indexOf('a') == 0)
                {
                Player1.Attack = 1;	
                }
        	    
        	    if (MoveSet.indexOf('s') == 0)
                {
                 Player1.Defense = 1;	
                }
        	    
        	    
        	      	   
        	   /* if (Levela[Snake1.UpDownLocation][Snake1.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Snake1.UpDownLocation][Snake1.LeftRightLocation  + 1] != '_' )
                if (Levela[Snake1.UpDownLocation][Snake1.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Snake1.UpDownLocation][Snake1.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Snake1.UpDownLocation][Snake1.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Snake1.UpDownLocation][Snake1.LeftRightLocation  + 1] != 'W' ) */
        	     
               if( Player1.UpDownLocation > Snake1.UpDownLocation && Snake1.MonsterAttack == 1)
               {
               	 Snake1.UpDownLocation += 1;
               	 
               }
        	   
        	 if( Player1.LeftRightLocation < Snake1.LeftRightLocation && Snake1.MonsterAttack == 1 )
               {
               	 Snake1.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Snake1.LeftRightLocation && Snake1.MonsterAttack == 1 )
               {
               	 Snake1.LeftRightLocation += 1;
               	
               }
        	  	
        	  	   if( Player1.UpDownLocation < Snake1.UpDownLocation && Snake1.MonsterAttack == 1 )
               {
               	 Snake1.UpDownLocation -= 1;
               	
               }
        	  
        	   
        	   
        	    if (Levela[Snake2.UpDownLocation][Snake2.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Snake2.UpDownLocation][Snake2.LeftRightLocation  + 1] != '_' )
                if (Levela[Snake2.UpDownLocation][Snake2.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Snake2.UpDownLocation][Snake2.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Snake2.UpDownLocation][Snake2.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Snake2.UpDownLocation][Snake2.LeftRightLocation  + 1] != 'W' )  
               if( Player1.UpDownLocation > Snake2.UpDownLocation && Snake2.MonsterAttack == 1)
               {
               	 Snake2.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Snake2.LeftRightLocation && Snake2.MonsterAttack == 1 )
               {
               	 Snake2.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Snake2.LeftRightLocation && Snake2.MonsterAttack == 1 )
               {
               	 Snake2.LeftRightLocation += 1;
               	
               }
        	  	
        	  		     
               if( Player1.UpDownLocation < Snake2.UpDownLocation  && Snake2.MonsterAttack == 1)
               {
               	 Snake2.UpDownLocation -= 1;
               }
        	  	 
        	 
        	    if (Levela[Snake3.UpDownLocation][Snake3.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Snake3.UpDownLocation][Snake3.LeftRightLocation  + 1] != '_' )
                if (Levela[Snake3.UpDownLocation][Snake3.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Snake3.UpDownLocation][Snake3.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Snake3.UpDownLocation][Snake3.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Snake3.UpDownLocation][Snake3.LeftRightLocation  + 1] != 'W' ) 
               if( Player1.UpDownLocation > Snake3.UpDownLocation && Snake3.MonsterAttack == 1)
               {
               	 Snake3.UpDownLocation += 1;
               }
        	   
        	  if( Player1.LeftRightLocation < Snake3.LeftRightLocation && Snake3.MonsterAttack == 1)
               {
               	 Snake3.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Snake3.LeftRightLocation && Snake3.MonsterAttack == 1)
               {
               	 Snake3.LeftRightLocation += 1;
               	
               }
        	  	 if( Player1.UpDownLocation < Snake3.UpDownLocation && Snake3.MonsterAttack == 1)
               {
               	 Snake3.UpDownLocation -= 1;
               }
        	     
        	  
        	    if (Levela[Snake4.UpDownLocation][Snake4.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Snake4.UpDownLocation][Snake4.LeftRightLocation  + 1] != '_' )
                if (Levela[Snake4.UpDownLocation][Snake4.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Snake4.UpDownLocation][Snake4.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Snake4.UpDownLocation][Snake4.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Snake4.UpDownLocation][Snake4.LeftRightLocation  + 1] != 'W' )  
               if( Player1.UpDownLocation > Snake4.UpDownLocation && Snake4.MonsterAttack == 1)
               {
               	 Snake4.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Snake4.LeftRightLocation && Snake4.MonsterAttack == 1)
               {
               	 Snake4.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Snake4.LeftRightLocation && Snake4.MonsterAttack == 1 )
               {
               	 Snake4.LeftRightLocation += 1;
               	
               }
        	  	    
               if( Player1.UpDownLocation < Snake4.UpDownLocation && Snake4.MonsterAttack == 1)
               {
               	 Snake4.UpDownLocation -= 1;
               }	
        	  	
        	    if (Levela[Snake5.UpDownLocation][Snake5.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Snake5.UpDownLocation][Snake5.LeftRightLocation  + 1] != '_' )
                if (Levela[Snake5.UpDownLocation][Snake5.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Snake5.UpDownLocation][Snake5.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Snake5.UpDownLocation][Snake5.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Snake5.UpDownLocation][Snake5.LeftRightLocation  + 1] != 'W' ) 
        	     
               if( Player1.UpDownLocation > Snake5.UpDownLocation && Snake5.MonsterAttack == 1 )
               {
               	 Snake5.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Snake5.LeftRightLocation && Snake5.MonsterAttack == 1 )
               {
               	 Snake5.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Snake5.LeftRightLocation && Snake5.MonsterAttack == 1 )
               {
               	 Snake5.LeftRightLocation += 1;
               	
               }
        	    
               if( Player1.UpDownLocation < Snake5.UpDownLocation && Snake6.MonsterAttack == 1 )
               {
               	 Snake5.UpDownLocation -= 1;
               }	
        	   
        	    if (Levela[Snake6.UpDownLocation][Snake6.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Snake6.UpDownLocation][Snake6.LeftRightLocation  + 1] != '_' )
                if (Levela[Snake6.UpDownLocation][Snake6.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Snake6.UpDownLocation][Snake6.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Snake6.UpDownLocation][Snake6.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Snake6.UpDownLocation][Snake6.LeftRightLocation  + 1] != 'W' )  
               if( Player1.UpDownLocation > Snake6.UpDownLocation && Snake6.MonsterAttack == 1  )
               {
               	 Snake6.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Snake6.LeftRightLocation && Snake6.MonsterAttack == 1 )
               {
               	 Snake6.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Snake6.LeftRightLocation && Snake6.MonsterAttack == 1  )
               {
               	 Snake6.LeftRightLocation += 1;
               	
               }
                  
               if( Player1.UpDownLocation < Snake6.UpDownLocation && Snake6.MonsterAttack == 1  )
               {
               	 Snake6.UpDownLocation -= 1;
               }
               
                if (Levela[Eagle1.UpDownLocation][Eagle1.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Eagle1.UpDownLocation][Eagle1.LeftRightLocation  + 1] != '_' )
                if (Levela[Eagle1.UpDownLocation][Eagle1.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Eagle1.UpDownLocation][Eagle1.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Eagle1.UpDownLocation][Eagle1.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Eagle1.UpDownLocation][Eagle1.LeftRightLocation  + 1] != 'W' ) 
               
        	   if( Player1.UpDownLocation < Eagle1.UpDownLocation && Eagle1.MonsterAttack == 1 )
               {
               	 Eagle1.UpDownLocation -= 1;
               	
               }
        	  
        	     
               if( Player1.UpDownLocation > Eagle1.UpDownLocation && Eagle1.MonsterAttack == 1 )
               {
               	 Eagle1.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Eagle1.LeftRightLocation && Eagle1.MonsterAttack == 1  )
               {
               	 Eagle1.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Eagle1.LeftRightLocation  && Eagle1.MonsterAttack == 1)
               {
               	 Eagle1.LeftRightLocation += 1;
               	
               }
        	  	
        	  	if (Levela[Eagle2.UpDownLocation][Eagle2.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Eagle2.UpDownLocation][Eagle2.LeftRightLocation  + 1] != '_' )
                if (Levela[Eagle2.UpDownLocation][Eagle2.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Eagle2.UpDownLocation][Eagle2.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Eagle2.UpDownLocation][Eagle2.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Eagle2.UpDownLocation][Eagle2.LeftRightLocation  + 1] != 'W' ) 
        	   if( Player1.UpDownLocation < Eagle1.UpDownLocation && Eagle2.MonsterAttack == 1 )
               {
               	 Eagle2.UpDownLocation -= 1;
               	
               }
        	  
        	     
               if( Player1.UpDownLocation > Eagle2.UpDownLocation  && Eagle2.MonsterAttack == 1)
               {
               	 Eagle2.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Eagle2.LeftRightLocation && Eagle2.MonsterAttack == 1 )
               {
               	 Eagle2.LeftRightLocation -= 1;
               	
               }
        	    if (Levela[Eagle3.UpDownLocation][Eagle3.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Eagle3.UpDownLocation][Eagle3.LeftRightLocation  + 1] != '_' )
                if (Levela[Eagle3.UpDownLocation][Eagle3.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Eagle3.UpDownLocation][Eagle3.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Eagle3.UpDownLocation][Eagle3.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Eagle3.UpDownLocation][Eagle3.LeftRightLocation  + 1] != 'W' ) 
        	   if( Player1.LeftRightLocation > Eagle3.LeftRightLocation && Eagle3.MonsterAttack == 1 )
               {
               	 Eagle3.LeftRightLocation += 1;
               	
               }
        	  	
        	   if( Player1.UpDownLocation < Eagle3.UpDownLocation  && Eagle3.MonsterAttack == 1 )
               {
               	 Eagle3.UpDownLocation -= 1;
               	
               }
        	  
        	     
               if( Player1.UpDownLocation > Eagle3.UpDownLocation  && Eagle3.MonsterAttack == 1 )
               {
               	 Eagle3.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Eagle3.LeftRightLocation && Eagle3.MonsterAttack == 1 )
               {
               	 Eagle3.LeftRightLocation -= 1;
               	
               }
        	  
        	    if (Levela[Eagle4.UpDownLocation][Eagle4.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Eagle4.UpDownLocation][Eagle4.LeftRightLocation  + 1] != '_' )
                if (Levela[Eagle4.UpDownLocation][Eagle4.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Eagle4.UpDownLocation][Eagle4.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Eagle4.UpDownLocation][Eagle4.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Eagle4.UpDownLocation][Eagle4.LeftRightLocation  + 1] != 'W' )  
               if( Player1.UpDownLocation > Eagle4.UpDownLocation && Eagle4.MonsterAttack == 1)
               {
               	 Eagle4.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Eagle4.LeftRightLocation && Eagle4.MonsterAttack == 1)
               {
               	 Eagle4.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Eagle4.LeftRightLocation && Eagle4.MonsterAttack == 1)
               {
               	 Eagle4.LeftRightLocation += 1;
               	
               }
        	   
        	   if( Player1.UpDownLocation < Eagle4.UpDownLocation && Eagle4.MonsterAttack == 1)
               {
               	 Eagle4.UpDownLocation -= 1;
               	
               }
        	  
        	    if (Levela[Eagle5.UpDownLocation][Eagle5.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Eagle5.UpDownLocation][Eagle5.LeftRightLocation  + 1] != '_' )
                if (Levela[Eagle5.UpDownLocation][Eagle5.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Eagle5.UpDownLocation][Eagle5.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Eagle5.UpDownLocation][Eagle5.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Eagle5.UpDownLocation][Eagle5.LeftRightLocation  + 1] != 'W' )  
               if( Player1.UpDownLocation > Eagle5.UpDownLocation && Eagle5.MonsterAttack == 1)
               {
               	 Eagle5.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Eagle5.LeftRightLocation && Eagle5.MonsterAttack == 1)
               {
               	 Eagle5.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Eagle5.LeftRightLocation && Eagle5.MonsterAttack == 1 )
               {
               	 Eagle5.LeftRightLocation += 1;
               	
               }
        	   
        	    
        	   if( Player1.UpDownLocation < Eagle5.UpDownLocation && Eagle5.MonsterAttack == 1 )
               {
               	 Eagle5.UpDownLocation -= 1;
               	
               }
        	   	if (Levela[Wolf1.UpDownLocation][Wolf1.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Wolf1.UpDownLocation][Wolf1.LeftRightLocation  + 1] != '_' )
                if (Levela[Wolf1.UpDownLocation][Wolf1.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Wolf1.UpDownLocation][Wolf1.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Wolf1.UpDownLocation][Wolf1.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Wolf1.UpDownLocation][Wolf1.LeftRightLocation  + 1] != 'W' ) 
        	   	if( Player1.UpDownLocation < Wolf1.UpDownLocation && Wolf1.MonsterAttack == 1)
               {
               	 Wolf1.UpDownLocation -= 1;
               	
               }
        	  
        	     
               if( Player1.UpDownLocation > Wolf1.UpDownLocation && Wolf1.MonsterAttack == 1 )
               {
               	 Wolf1.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Wolf1.LeftRightLocation && Wolf1.MonsterAttack == 1)
               {
               	 Wolf1.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Wolf1.LeftRightLocation && Wolf1.MonsterAttack == 1)
               {
               	 Wolf1.LeftRightLocation += 1;
               	
               }
        	  	if (Levela[Wolf2.UpDownLocation][Wolf2.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Wolf2.UpDownLocation][Wolf2.LeftRightLocation  + 1] != '_' )
                if (Levela[Wolf2.UpDownLocation][Wolf2.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Wolf2.UpDownLocation][Wolf2.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Wolf2.UpDownLocation][Wolf2.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Wolf2.UpDownLocation][Wolf2.LeftRightLocation  + 1] != 'W' ) 
        	  	  	if( Player1.UpDownLocation < Wolf2.UpDownLocation && Wolf2.MonsterAttack == 1)
               {
               	 Wolf2.UpDownLocation -= 1;
               	
               }
        	  
        	     
               if( Player1.UpDownLocation > Wolf2.UpDownLocation && Wolf2.MonsterAttack == 1)
               {
               	 Wolf2.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Wolf2.LeftRightLocation && Wolf2.MonsterAttack == 1 )
               {
               	 Wolf2.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Wolf2.LeftRightLocation && Wolf2.MonsterAttack == 1)
               {
               	 Wolf2.LeftRightLocation += 1;
               	
               }
        	  	if (Levela[Wolf3.UpDownLocation][Wolf3.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Wolf3.UpDownLocation][Wolf3.LeftRightLocation  + 1] != '_' )
                if (Levela[Wolf3.UpDownLocation][Wolf3.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Wolf3.UpDownLocation][Wolf3.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Wolf3.UpDownLocation][Wolf3.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Wolf3.UpDownLocation][Wolf3.LeftRightLocation  + 1] != 'W' ) 
        	  	if( Player1.UpDownLocation < Wolf3.UpDownLocation && Wolf3.MonsterAttack == 1 )
               {
               	 Wolf3.UpDownLocation -= 1;
               	
               }
        	  
        	     
               if( Player1.UpDownLocation > Wolf3.UpDownLocation && Wolf3.MonsterAttack == 1)
               {
               	 Wolf3.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Wolf3.LeftRightLocation && Wolf3.MonsterAttack == 1)
               {
               	 Wolf3.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Wolf3.LeftRightLocation && Wolf3.MonsterAttack == 1)
               {
               	 Wolf3.LeftRightLocation += 1;
               	
               }
        	  	if (Levela[Wolf4.UpDownLocation][Wolf4.LeftRightLocation  + 1] != '|' ) 
                if (Levela[Wolf4.UpDownLocation][Wolf4.LeftRightLocation  + 1] != '_' )
                if (Levela[Wolf4.UpDownLocation][Wolf4.LeftRightLocation  + 1] != 'P' )		
                if (Levela[Wolf4.UpDownLocation][Wolf4.LeftRightLocation  + 1] != 'S' ) 
                if (Levela[Wolf4.UpDownLocation][Wolf4.LeftRightLocation  + 1] != 'E' ) 
                if (Levela[Wolf4.UpDownLocation][Wolf4.LeftRightLocation  + 1] != 'W' ) 
        	  	  	if( Player1.UpDownLocation < Wolf1.UpDownLocation && Wolf4.MonsterAttack == 1 )
               {
               	 Wolf4.UpDownLocation -= 1;
               	
               }
        	  
        	     
               if( Player1.UpDownLocation > Wolf4.UpDownLocation && Wolf4.MonsterAttack == 1)
               {
               	 Wolf4.UpDownLocation += 1;
               }
        	   
        	 if( Player1.LeftRightLocation < Wolf4.LeftRightLocation && Wolf4.MonsterAttack == 1)
               {
               	 Wolf4.LeftRightLocation -= 1;
               	
               }
        	    
        	   if( Player1.LeftRightLocation > Wolf4.LeftRightLocation && Wolf4.MonsterAttack == 1 )
               {
               	 Wolf4.LeftRightLocation += 1;
               	
               }
        	  	
        	  		
        	  	
        	  }		
        	  	
        	  	
        		if (Options == 1)
        		{
        			frame2.setVisible(true);
        			frame.setVisible(false);
        			Options = 0;
        		}			
        		
        		if (Credits == 1)
        		{
        			frame3.setVisible(true);
        			frame.setVisible(false);
        			Credits = 0;
        		}	
        	
        		if (QuitGame == 1)
        		{
        			System.exit(0);
        		}			
        	}   	
        	
        }
        
      static class KeyboardPanel extends JPanel
      {
      	private int x = 100;
      	private int y = 100;
      	private char keyChar = 'A';
      	
      	public KeyboardPanel()
      	{
      		addKeyListener(new KeyAdapter()  {
      			public void keyPressed(KeyEvent e) {
      				
      				switch (e.getKeyCode())
      				{
      					case KeyEvent.VK_M: MainMenu = 1; break;
      				    case KeyEvent.VK_Q: QuitGame = 1; break;
      				    case KeyEvent.VK_C:	Credits = 1; break;
      					case KeyEvent.VK_N:	NewGame = 1; break;
      					case KeyEvent.VK_O: Options = 1; break;
      				
      					default: keyChar = e.getKeyChar();
      				}	
      			
      			      repaint();
      			}	
      	});
      }
        
      
        
      }  
    }
    please, lend me a hand. I would greatly appreciate it.

    Moderator Edit: Code tags added
    Last edited by Fubarable; 05-15-2010 at 03:13 AM. Reason: Moderator Edit: Code tags added

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    283
    Rep Power
    8

    Default

    Please use code tags to show your code, and what problem are you facing in converting it into applet?
    Swastik

  3. #3
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    10

    Default

    So where exactly are you stuck?

    P.S Posting all that code was not really neccessary.

  4. #4
    Rekuta is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    To be more specific, I am trying to see how i can use my program as an applet instead of JFrame : so instead of using
    public class RPG14 extends JFrame
    I would like to use
    public class RPG14 extends Applet.
    But I don't know how to put the lines of my program the way Applet wants them in order to work.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    28

    Default

    Change your GUI to either extend or (better) produce a JPanel. Then you can place that JPanel in a JFrame's contentPane if you want to display the program as a JFrame or in a JDialog, or another JPanel, or even a JApplet's contentPane.

  6. #6
    Rekuta is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    And how do i change my JFrame GUI to serve an Applet contentFrame ?

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    28

    Default

    Quote Originally Posted by Rekuta View Post
    And how do i change my JFrame GUI to serve an Applet contentFrame ?
    Check out the Sun Swing tutorials as they will show you how to create JPanels instead of JFrames. They'll also show you how to place a JPanel into a JFrame or JApplet.

    Much luck!

  8. #8
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Lightbulb

    Quote Originally Posted by Rekuta View Post
    And how do i change my JFrame GUI to serve an Applet contentFrame ?
    Fubarable is right... The easiest way to modify a JFrame to Applet it is using JPanel component.

    But I would also recommend not to use awt Applet but to use swing JApplet instead. So you can extend it as a JFrame. the only thing you need then is to write main method instead of the init one :)

    PS. The code you provide is too long. Please specify the problem lines more briefly...
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  9. #9
    Rekuta is offline Member
    Join Date
    May 2010
    Posts
    6
    Rep Power
    0

    Default

    And if i try to create a Panel and a swing applet, do I copy and paste my main into the init of the swing applet ?

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    28

    Default

    It's not quite that simple. The tutorials I think should show what inits should contain. Myself, I usually base my JApplet init on a template like this one:

    Java Code:
    import javax.swing.JApplet;
    
    public class MyApplet extends JApplet {
      public void init() {
        try {
          javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
              createGUI();
            }
          });
        } catch (Exception e) {
          System.err.println("createGUI didn't successfully complete");
        }
      }
    
      private void createGUI() {
        // create JPanel and add to JApplet's contentPane
        getContentPane().add(new MyJPanel());
      }
    }
    But again, this code is based on information that I found in the tutorials
    YMMV

    Luck.

Similar Threads

  1. Applet in JFrame, JMenu problem
    By Bill86 in forum New To Java
    Replies: 5
    Last Post: 12-28-2009, 05:20 AM
  2. Embed java applet in JFrame
    By Bill89 in forum New To Java
    Replies: 0
    Last Post: 12-09-2009, 02:05 PM
  3. a simple conversion problem
    By sweetjava in forum New To Java
    Replies: 3
    Last Post: 07-20-2009, 06:34 AM
  4. Problem in TIFF Conversion
    By lakshmipriyam in forum Advanced Java
    Replies: 1
    Last Post: 08-09-2007, 10:44 PM
  5. JFrame vs Applet
    By baltimore in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 03:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •