Results 1 to 7 of 7
  1. #1
    btap0644 is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Smile Cannot see the gui for the SingleLaneBridge java applet example

    Hi,

    I went to the this java site (Single Lane Bridge) and loaded the files in a new project in netbeans 6.8 . I removed the package declaration and put them in the default package of the project. I tried to compile it by right clicking and selecting run(Shift + F6) on the SingleLaneBridge.java file. This program compiled without errors.

    This is what I got :




    Then I tried another method, which included copying the java files to a folder and compiled them manually using commandLine. Then made an html file and put the reference to the SingleLaneBridge.class file. Still I got a similar grey screen with the buttons. Then I tried again by downloading the pictures and the sound file (Note: All this time images and the sound file were called from the website):

    1)Red car (http://wwwhomes.doc.ic.ac.uk/~jnm/bo...age/redcar.gif)

    2)Blue car (http://wwwhomes.doc.ic.ac.uk/~jnm/bo...ge/bluecar.gif)

    3)Bridge (http://wwwhomes.doc.ic.ac.uk/~jnm/bo...age/bridge.gif)

    4)Crash sound file (http://wwwhomes.doc.ic.ac.uk/~jnm/bo...sound/crash.au)

    Then I put the images in the folder where the notepad files were. The image and sound path(s) was set appropriately in the BridgeCanvas.java file so dont worry about that.

    After this I tried it out in Eclipse as well. But the same gray applet window with buttons showed up.

    I would like to see the cars and bridge in the applet, like in this site (Single Lane Bridge).

    Thanks for your time.

    Tlna

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

    Default

    Your problem is that you don't know where the image files should be in order for your program to access them. Putting the images in the folder containing the .java files for example is not going to help you because those are the source files and they are not consulted when the program is run.

    Where to place the images depends on how the program is trying to load the files. Generally you'll want them to be in some folder that is on the classpath (Note that, generally, classpath != source files path).

  3. #3
    btap0644 is offline Member
    Join Date
    Jun 2010
    Posts
    3
    Rep Power
    0

    Smile

    Quote Originally Posted by r035198x View Post
    Your problem is that you don't know where the image files should be in order for your program to access them. Putting the images in the folder containing the .java files for example is not going to help you because those are the source files and they are not consulted when the program is run.

    Where to place the images depends on how the program is trying to load the files. Generally you'll want them to be in some folder that is on the classpath (Note that, generally, classpath != source files path).

    Dear r035198x,

    Thanks for the reply.

    Trust me, the image path is not the problem. I downloaded the files and put in right folders. I have done this image path thing before quite alot of times. For example, I did the this thing in Netbeans and Eclipse both. Paths of both differ in a small way when setting up (you would probably know that).

    Do you have any other reason why this is happening ??

    Thank you once again for your time.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Try debugging the code by trying different paths or by copying the images to all the possible places that the code could look.
    When it finds them, start removing them until you find the one that was used.
    any other reason why this is happening
    There are many ways for a code not to work. Too many to list here.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

  6. #6
    codVal is offline Member
    Join Date
    Apr 2014
    Posts
    1
    Rep Power
    0

    Default Re: Cannot see the gui for the SingleLaneBridge java applet example

    I'm using eclipse IDE but i'm sure you'll understand these steps:
    1. in the source folder where you kept all the codes i.e bridge canvas etc, create two new folders (not source folders) for 'sound' and 'image'
    2. place all the images and sound files in the respective folders and it should work

    Cheers..

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Cannot see the gui for the SingleLaneBridge java applet example

    This thread is 4 years old.
    Closed
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Help with java applet
    By ketann in forum Java Applets
    Replies: 0
    Last Post: 03-22-2010, 01:06 AM
  2. Help with this java applet
    By dementedchild686 in forum Java Applets
    Replies: 5
    Last Post: 03-14-2010, 11:53 AM
  3. How do i fix this Java applet ??????
    By danielmessick in forum JCreator
    Replies: 1
    Last Post: 03-07-2010, 12:55 PM
  4. Replies: 3
    Last Post: 07-23-2008, 08:07 AM
  5. Java Applet Help
    By Nuluvius in forum New To Java
    Replies: 0
    Last Post: 03-01-2008, 03:04 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
  •