Smithers1041
asked on
Assigning Class To JFrame
Hi,
I am a student studying network management. Within this course we have to do a unit on java. I find programing very difficult. Our coursework is to build a java chess game.
We have been given a Chess Board as an external class that we have to use.
But when I try
new Board().setVisible(true);
I get an error message “cannot find symbol”
This was the way we were tought in the lectures.
I attached the Main.java & Class (Board.java) in question.
I am using Netbeans 6.9
Any help will be much appreciated
Regards
Thomas
Main.java Board.java
I am a student studying network management. Within this course we have to do a unit on java. I find programing very difficult. Our coursework is to build a java chess game.
We have been given a Chess Board as an external class that we have to use.
But when I try
new Board().setVisible(true);
I get an error message “cannot find symbol”
This was the way we were tought in the lectures.
I attached the Main.java & Class (Board.java) in question.
I am using Netbeans 6.9
Any help will be much appreciated
Regards
Thomas
Main.java Board.java
Have you created a project in Netbeans?
ASKER
Yes, called JavaChess contains the two files Main.java & Board.java !
Your code compiles fine for me.
Maybe you called the folder JavaChess
but it should be javachess and in the code in lower case ?
Java ias case sensiitive
Maybe you called the folder JavaChess
but it should be javachess and in the code in lower case ?
Java ias case sensiitive
In netbeeans if you creare project
javachess
it will create folder for package with the same name
The case of the package in the fiolder name and the one you see on top of your code
should be the same. Usually packages in Java are lower case
javachess
it will create folder for package with the same name
The case of the package in the fiolder name and the one you see on top of your code
should be the same. Usually packages in Java are lower case
Create a package called 'javachess' off your source root. Move the .java files into there and delete any others
you can either:
1. remove the package statements in both classes, or
2. Move the source into folder of the same name as package
Reda the following for some background
http://download.oracle.com/javase/tutorial/java/package/packages.html
1. remove the package statements in both classes, or
2. Move the source into folder of the same name as package
Reda the following for some background
http://download.oracle.com/javase/tutorial/java/package/packages.html
ASKER
Okay, rebuild project & copied the same code In, and it worked (well sort off) but i get a new problem
"Netbeans Debug Output"
Exception in thread "main" java.lang.NullPointerExcep tion
at javax.swing.ImageIcon.<ini t>(ImageIc on.java:16 7)
at javachess.Board.PaintPiece (Board.jav a:137)
at javachess.Board.RepaintPie ces(Board. java:161)
at javachess.Board.resetPiece s(Board.ja va:130)
at javachess.Board.newGame(Bo ard.java:5 9)
at javachess.Board.InitPieces (Board.jav a:64)
at javachess.Board.<init>(Boa rd.java:32 )
at javachess.Main.main(Main.j ava:19)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
Any Idea's ?
"Netbeans Debug Output"
Exception in thread "main" java.lang.NullPointerExcep
at javax.swing.ImageIcon.<ini
at javachess.Board.PaintPiece
at javachess.Board.RepaintPie
at javachess.Board.resetPiece
at javachess.Board.newGame(Bo
at javachess.Board.InitPieces
at javachess.Board.<init>(Boa
at javachess.Main.main(Main.j
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
Any Idea's ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I actually placed a gif file into
..\netbeans_projects\javac
and named it clear.gif and it worked for me nicely