Results 1 to 2 of 2
  1. #1
    halo1303 is offline Member
    Join Date
    Feb 2011
    Posts
    1
    Rep Power
    0

    Exclamation java static help

    so im making this game where i have a method call another method in another class but im getting a
    "Cannot make a static reference to the non-static method First() from the type Classtwo" error

    now i looked it up but it was confusing on how to fix it as i am vary new at java

    ill post the relevant code(sorry about the random lines in there i have been trying to figure it out myself for a long time :p :


    Java Code:
    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.geom.AffineTransform;
    
    
    
    
    
    
    public class NearMiss extends Applet implements Runnable, KeyListener
    {
    	private Player player;
    	private Player TurnClockwise;
    	
    
    public void keyPressed(KeyEvent e)
    {
    	int key = e.getKeyCode();
    	keys[key]=true;
    	
    	System.out.println("User pressed key " + e.getKeyCode() +keys[key]+ Player.Dplayer_info[1]);	
    }
    
    public void keyReleased(KeyEvent e)
    {
    	int key = e.getKeyCode();
    	keys[key]=false;
    	
    	System.out.println("User released key " +keys[key]+ e.getKeyCode());	
    }
    
    
    public void run ()
    {
    	Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
    	while(true)
    	{		
    		if (keys[39] = true )
    		{
    			Player.TurnClockwise();
    		}
    		repaint();
        	
            try
            {
                Thread.sleep (10);
            }
            catch (InterruptedException ex)
            {
                // do nothing
            }
    
            Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    	}
    
    
    ///Class2
    
    
    public class Player
    {
    		
    		public  double Dplayer_info[]=new double[10] ;
    		
    		
    	public Player()
    	{      Dplayer_info[1] = 1;
    		Dplayer_info[2] = 10;
    		Dplayer_info[3]	= 0;
    		
    	}
    
    	
    	
    	
    	
    	
    	public  void TurnClockwise()
    	{
    		Dplayer_info[1] = Dplayer_info[1] + Dplayer_info[2];
    		System.out.println(Dplayer_info[1]);
    	}
    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Hmmm

    I don't see any static methods in the code posted. I don't see a method called First in the code posted. I dont see a class called Classtwo in the code posted.

    Do you think we read minds?

Similar Threads

  1. Replies: 7
    Last Post: 09-24-2010, 05:09 AM
  2. Replies: 4
    Last Post: 05-12-2010, 11:05 AM
  3. Replies: 3
    Last Post: 02-09-2010, 05:22 AM
  4. Replies: 1
    Last Post: 08-07-2007, 05:05 AM
  5. Replies: 1
    Last Post: 08-01-2007, 09:25 PM

Tags for this Thread

Posting Permissions

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