Results 1 to 3 of 3
  1. #1
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,037
    Rep Power
    8

    Default strange stuff why is it (not) working

    Why the first Icon download works and the second not


    Java Code:
        try {
                 appletp = new URL(getCodeBase(), "slideshowImages" +
                         File.separator + "calella" );
                 flag = true;
            } catch (IOException ex) {
                System.out.println("can not read current image folder : " + "calella" );
                System.out.println(ex.getMessage());
                flag = false;
            }  appletPath = appletp;

    this one works but it shouldn't because of a double getCodeBase

    Java Code:
    URL url = new URL(getCodeBase(),
                    appletPath +   File.separator +  Iname); // Iname is the name of the icon
                    Iicon = new ImageIcon(url);
             }
             catch (IOException e) {
                    System.out.println(" path error "  +
                                     "images" + Iname);
             }
    this next one gives a applet security error


    Java Code:
    URL url = new URL(getDocumentBase(),
      			"slideshowImages" +
                               File.separator + "calella" +
                               File.separator +  Iname);
    
                      Iicon = new ImageIcon(url);
             }
             catch (IOException e) {
                    System.out.println(" path error "  +
                                     "images" + Iname);
             }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: strange stuff why is it (not) working

    Print out the values you are using.
    So what getCodeBase() returns, and getDocumentBase(), and also the result of your various concatenations.

    Also you need to post the full exception, and I would recommend using printStackTrace().
    Please do not ask for code as refusal often offends.

  3. #3
    willemjav is offline Senior Member
    Join Date
    Dec 2007
    Location
    Spain
    Posts
    1,037
    Rep Power
    8

    Default Re: strange stuff why is it (not) working

    (sorry for responding some later)
    Toll I did print out getCodeBase() etc. of course!
    The strange thing is that I have the applet working, using codebase.
    It works from a file folder which contains the classes and the applet tag.
    When I move that file folder at what ever position (external hard disk) on my
    Mac, the applet still goes without problems.
    Bur when I move the file folder to the computer of my son (a PC) it wont
    start.....
    But ok maybe when uploaded on a server all these problems will disappear
    (or maybe not?)

Similar Threads

  1. New to this stuff.. need help..
    By tkelley1620 in forum New To Java
    Replies: 3
    Last Post: 03-07-2012, 12:34 AM
  2. where the stuff goes?
    By Izabela in forum New To Java
    Replies: 16
    Last Post: 08-31-2010, 02:00 PM
  3. JButton actionlistener not working, very strange
    By alacn in forum New To Java
    Replies: 4
    Last Post: 08-05-2010, 02:25 AM
  4. Replies: 6
    Last Post: 05-26-2010, 12:17 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
  •