DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: images not loading

  1. #1
    Join Date
    Apr 2006

    images not loading

    hi, my problem is that i run my applet on a html page(the one on the classes folder) and i can see the JLabels and JTextfields i created....but cant look at the images i put there using the method JLabel(new ImageIcon("file.jpg"))
    but i can watch it when running my applet inside JCrator..just not when double clicking the html any idea?
    by the way, i already made a FilePermission on the policytool file over javas folder.

  2. #2
    Join Date
    Mar 2006
    we need more info
    could you post your code..

  3. #3
    Join Date
    Apr 2006

    something weird happened

    hi..thakns for the interest on helping me out..but i kinda figured out the least i can load the pics and other external files like txt.
    ill explain it all to u: i did a lil program on java and it really works properly when i run it from JCreator(pressing the F5 key). It loads all the images and also it reads and writes to the txt files on the classes folder...
    but then, when i run it directly from the html file on the classes folder, it wouldnt load anything(either pics or txts) so i searched around and i was told there was some permission i gotta do on the policytool file on javas folder...i did so and saved the norm( the ".java.policy" file) on this route: c:\documents and settings\mario\
    but it wouldnt wrk properly
    for some reason i pasted the pics and txts on the desktop and now it reads them! but...i dont really wanna have all that in the like to be able to determinate from which folder should the program take the pics and txts from....but dont know where i should do so...uve got an idea?
    im not sure if this prob is common or not, im kinda newbie at java...
    hope u can help me out...thanks.
    sorry i dont post my code, but im sure the prob is not there, coz as i would run properly when doing it on JCreator..
    the prob was first the file permissions to read, write and that....but i solved that....
    now the prob is that the program is using the desktop for default to take the files from like to change the folder, so it can read the files from some other route.

  4. #4
    Join Date
    Mar 2006
    when you create a program, it always uses the files within the same directory

    so with the following code:
    FileReader fr = new FileReader("text.txt");
    when you save your program into the following directory:
    c:\documents and settings\mario\application\
    and the directory 'application' contains 'text.txt' it will read the file in that specific directory

    you could also specify your directory through the FileReader like this:
    FileReader fr = new FileReader("c:/documents and settings/mario/application/text.txt");

    that way you can choose where to place your files
    it all depends where you execute your application or applet, or in your case your html file

    note: you have to use '/' in stead of '\' because the first one is a reserved symbol in java

Similar Threads

  1. Replies: 1
    Last Post: 03-10-2006, 05:02 PM
  2. WAR Deployment - Images not loading
    By gokulram in forum Java
    Replies: 0
    Last Post: 03-18-2005, 12:58 PM
  3. Loading Images into JavaScript.
    By Scott in forum Web
    Replies: 1
    Last Post: 10-31-2002, 08:44 PM
  4. loading images dynamically is slow
    By Michael Shutt in forum Web
    Replies: 0
    Last Post: 06-26-2001, 02:25 PM
  5. Replies: 0
    Last Post: 01-02-2001, 08:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center