Advertisement

04.23.2008 at 06:10AM PDT, ID: 23346345
[x]
Attachment Details

non-static variable cannot be referenced from a static context  ????

Asked by perdoname_ in Java Programming Language, Programming Languages

Hello Experts,

I need your assistance about the following errors:
MovingTilesApp.java:64: non-static variable mapHeight cannot be referenced from a static context
            for(int a=0;a<LODServer.mapHeight;a++)
                                       ^
MovingTilesApp.java:66: non-static variable mapWidth cannot be referenced from a static context
                  for(int b=0;b<LODServer.mapWidth;b++)
                                               ^
MovingTilesApp.java:68: non-static variable map cannot be referenced from a static context
                        switch(LODServer.map[a][b])
                                                ^




Thanks in advance for any help !Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
import javax.swing.JFrame;
import java.awt.GraphicsConfiguration;
 
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
 
public class MovingTilesApp extends JFrame {
	//SG_Board myBoard;
	MyEnhancedBoard myBoard;
 
	public Container contentPane;
	public MovingTilesApp() {
		setTitle("Labyrinth");
		setVisible( true ) ;
		setSize(450,300); // Any size, reset it later.
		contentPane = getContentPane();
		contentPane.setLayout(new BorderLayout());
 
		//Note This image is 640x480 pixels
		// public SG_Board (String file_name, int buffer,
		//              int x0, int y0,
		//              int posnsWide, int posnsDown,
		//              int posnPixelsWide, int posnPixelsDown){
 
		myBoard = new MyEnhancedBoard("Blank.jpg",0,0,10,8,64,60);
		// Note: The image in 'Uluru.jpg' becomes the background graphic, covering
		// the whole board. It will be divided into rectangles automatically, by
		// default.
		myBoard.setNoOfTiles(5); // Total number of playing tiles to Initialise
		//setTile(int tileId, int boardCoordX,int boardCoordY,String iconName)
		myBoard.setTile(1,1,1,"Cool1.jpg"); 
 
		contentPane.add("Center",myBoard);
		//contentPane.add();
		JButton goUpButton = new JButton("Up");
		JButton goDownButton = new JButton("Down");
		JButton goLeftButton = new JButton("Left");
		JButton goRightButton = new JButton("Right");
 
		goUpButton.addActionListener(myBoard);
		goDownButton.addActionListener(myBoard);
		goLeftButton.addActionListener(myBoard);
		goRightButton.addActionListener(myBoard);
		contentPane.add("West",goLeftButton);
		contentPane.add("East",goRightButton);
		contentPane.add("North",goUpButton);
		contentPane.add("South", goDownButton);
 
		PrintMap();
 
 
		resize(770,575);
		show();
	}
	public static void main(String[] args) {
		MovingTilesApp myBoardGame = new MovingTilesApp();
	}
 
	public void PrintMap()
	{
		for(int a=0;a<LODServer.mapHeight;a++)
		{
			for(int b=0;b<LODServer.mapWidth;b++)
			{
				switch(LODServer.map[a][b])
				{									       /*tileId,x,y*/
 
					case LODServer.EMPTY :   myBoard.setTile(2,a,b,"floor.jpg"); break;
					case LODServer.HEALTH :  myBoard.setTile(3,a,b,"health.jpg"); break;
					case LODServer.LANTERN : myBoard.setTile(4,a,b,"lantern.jpg"); break;
					case LODServer.SWORD :   myBoard.setTile(5,a,b,"sword.jpg"); break;
					case LODServer.ARMOUR :  myBoard.setTile(6,a,b,"armour.jpg"); break;
					case LODServer.EXIT :    myBoard.setTile(7,a,b,"exit.jpg"); break;
					case LODServer.WALL :    myBoard.setTile(8,a,b,"wall.jpg"); break;
				}
 
			}
		}
	}
 
 
 
}
[+][-]04.23.2008 at 06:12AM PDT, ID: 21420240

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Programming Language, Programming Languages
Sign Up Now!
Solution Provided By: CEHJ
Participating Experts: 3
Solution Grade: B
 
 
[+][-]04.23.2008 at 06:16AM PDT, ID: 21420286

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.23.2008 at 06:17AM PDT, ID: 21420298

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628