Applet Not Updating Or Displaying OptionPanes
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Applet Not Updating Or Displaying OptionPanes

  1. #1
    Join Date
    Dec 2010
    Posts
    2

    Post Applet Not Updating Or Displaying OptionPanes

    I have written a java application based on two classes. The Application runs perfectly fine when I execute it from the development tool (Eclipse). I have posted the files to my webpage and the applet display, but nothing else works. The ActionListeners don't seem to do anything, but it doesn't seem to be throwing an error. Below is some info if someone can help me debug:

    My Site: http://community.wvu.edu/~lcs009/

    each class's html page has the following html to start the applet:
    <HTML>
    <HEAD>
    <TITLE>Logan's Quiz</TITLE>
    </HEAD>
    <BODY>
    Welcome to Logan's Interactive Quiz!:



    <applet code="quiz.class" archive = "run_quiz.jar" width="300" height ="300">
    </applet>

    </BODY>
    </HTML>

    more info:

    For the quiz page, it should either say "file could not be read" or display option panes for a list of questions. You should be able to use example.txt as the file name which is stored in the same folder on the website.

    The scores page should then display additional labels with your score history, the username "logan" should be a good test.

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Applet Not Updating Or Displaying OptionPanes

    Without seeing the code we can only guess. My guess is it is a security restriction that causing the problem especially if you are trying to load a file. Make sure you really are trying to load the file from the server and not from the local file system.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Dec 2010
    Posts
    2

    Re: Applet Not Updating Or Displaying OptionPanes

    I had worried that was the issue, so I put the buffered reader into a try catch block, which the catch block should add a label "file could not be read", but nothing happens. if you were to click the button in the working applet without inputting anything, it obviously returns an error, which isn't happening either. Is there something more general with my HTML portion or security that needs set up to enable anything about the applet to change?

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Applet Not Updating Or Displaying OptionPanes

    Have you tried looking in the browser's java console to see if any error messages appear there?
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  5. #5
    Join Date
    Dec 2010
    Posts
    2

    Re: Applet Not Updating Or Displaying OptionPanes

    ! smart man

    I get the AccessControlException displayed in the console. Now I am trying to read from my own C drive, so why am I getting this error?


    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.io.FilePermission C:\example.txt read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkRead(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileReader.<init>(Unknown Source)
    at quiz.runQuiz(quiz.java:59)
    at quiz.actionPerformed(quiz.java:37)
    at java.awt.Button.processActionEvent(Unknown Source)
    at java.awt.Button.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

  6. #6
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Applet Not Updating Or Displaying OptionPanes

    Now I am trying to read from my own C drive, so why am I getting this error?
    Because applets are restricted in what thy can do, in particular for things like reading files from and writing files to the client's hard drive.

    I thought you said you were loading the file from the server?

    If you really must have access to the clients drive you can sign your applet to create a "trusted" applet and then it's up to the user if he/she is willing to allow your applet to access their drive.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center