• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

traffic simulation

 
shepherd chagwedera
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there

I have a traffic simulation code that is producing a start:applet not initialized error each time i run it. Can u pliz have a look at my code and help me

this is the code

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to compile, I changed
Graph graph
to JPanel graph

compiled/ran, error, opened java console which showed
NumberFormatException, line 574
which is this line
carnum = Integer.parseInt(getParameter("carnum"));

changed to a hard-coded value
carnum = Integer.parseInt("10");

and the applet started OK
 
Sujitha Gali
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made the corrections that you mentioned above but
I am still getting an error as below:

panel = new GraphPanel(this);
Its showing
constructor GraphPanel in class project.GraphPanel cannot be applied to given types;
required:javax.swing.JPanel
found:project.Graph
reason:actual argument project.Graph cannot be converted to javax.swing.JPanel by method invocation conversion
Its asking to create constructor GraphPanel(project.Graph) in project.GraphPanel
How to solve this?
 
saifullah khan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When i run the Traffic Simulation Code
error java in 565 line  public class Graph extends error in only public

EDIT: (SNIP of code copied and pasted from above without code tags)

please correct this code and send me on saifciit119@gmail.com
 
Norm Radder
Bartender
Posts: 1237
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
error java in 565 line

Please copy the full text of the error message and paste it here. It has important info about the error.
 
saifullah khan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sir this is the Compilation time Picture .... in Traffic Simulation please Solve this problem

public class Graph extends java.applet.Applet

error are come in class

erry.PNG
[Thumbnail for erry.PNG]
 
Norm Radder
Bartender
Posts: 1237
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not possible to copy text from an image to include in a response. And the image is not shown while I make this response so I can't see it now.

Please copy the text of the message and paste it here.
 
Stefan Evans
Bartender
Posts: 1780
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message from the screenshot:

"Node.java:565 : error: class Graph is public and should be declared in a file named Graph.java"

I think the error message makes it pretty clear what is wrong and what you have to do.

@saifullah khan
Please remember that JavaRanch is NotACodeMill.
Asking for people to correct your code and send to your personal email is not the way things are done here.
You can ask for help certainly, but the whole point is that we help you to help yourself.
 
saifullah khan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sir this is the Complete Msg of Error

C:\Users\SaifUllah Khan\Desktop>javac Node.java                               
Node.java:565: error: class Graph is public, should be declared in a file named
Graph.java                                                                     
public class Graph extends java.applet.Applet {                                       
^                                                                      
Note: Node.java uses or overrides a deprecated API.                            
Note: Recompile with -Xlint:deprecation for details.                          
1 error                                                                                                                                                       
C:\Users\SaifUllah Khan\Desktop>   




Please Help me Sir
Saifciit119@gmail.com
 
Norm Radder
Bartender
Posts: 1237
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Node.java:565: error: class Graph is public, should be declared in a file named Graph.java                                                      

There can only be one public class in a source file.
Either move the Graph class to its own file named: Graph.java
or remove the public attribute.  There can be more than one non-public class in a source file.

 
saifullah khan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sir when i changed the file name  Node.java to Graphics.java
and compile the Whole Programs then  this message show on the CMD

Note:Graph.java uses or overrides a deprecared API.
Note:Recompile with -Xlint:deprecation for details.
 
saifullah khan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saifullah khan wrote:
Sir when i changed the file name  Node.java to Graph.java
and compile the Whole Programs then  this message show on the CMD

Note:Graph.java uses or overrides a deprecared API.
Note:Recompile with -Xlint:deprecation for details.
 
Norm Radder
Bartender
Posts: 1237
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The message says what to do for more information:
Recompile with -Xlint:deprecation for details.

Here's the commandline I use to compile java programs:
C:\Program Files\Java\jdk1.8.0_60\bin\javac.exe -cp . -Xlint -Xdiags:verbose TestCode22.java
 
saifullah khan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i don not  know sir what you  say about this error  i need the Correct Code   then send me on
saifciit119@gmail.com
 
Norm Radder
Bartender
Posts: 1237
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
about this error

The compiler told you to use the -Xlint javac option when you compile the source so that you get the full text of the message.

It looks like the message is only a warning, so you should be able to execute the code to test it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic