Results 1 to 4 of 4
  1. #1
    Viola is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default Execute code from ActionListener

    Hello everyone,

    I am new to this forum and very very new to Java, so please ignore my ignorance :)

    I've implemented button in Applet, using actionPerformed to make it do some action. Button works when interacting with some of textboxes but no when I try for example to delete a textfile. The code for deleting is correct and works when executed from main method.

    How can I make the delete code to be executed after the button is pressed???

    Thank for any help.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,573
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Viola View Post
    Hello everyone,

    I am new to this forum and very very new to Java, so please ignore my ignorance :)

    I've implemented button in Applet, using actionPerformed to make it do some action. Button works when interacting with some of textboxes but no when I try for example to delete a textfile. The code for deleting is correct and works when executed from main method.

    How can I make the delete code to be executed after the button is pressed???

    Thank for any help.
    You wrote about an Applet and a main( ... ) method; Applets don't have a main( ... ) method so I assume you tested your code in an ordinary application where it works while it doesn't work in your Applet. Applets run under a SecurityManager that doesn't allow access to the filing system. Applications can do what they want.

    kind regards,

    Jos

  3. #3
    Viola is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default

    Thank you very much for your help. Now I understand the problem.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,573
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Viola View Post
    Thank you very much for your help. Now I understand the problem.
    You're welcome of course; there is a way to make your Applet a 'trusted' applet so it can access filing systems on its target host. Google for it because I don't know much about that stuff.

    kind regards,

    Jos

Similar Threads

  1. NullPointerException by ActionListener
    By YouGina in forum AWT / Swing
    Replies: 8
    Last Post: 07-10-2009, 11:08 AM
  2. Compile/Execute code in Java app
    By Doctor Cactus in forum New To Java
    Replies: 5
    Last Post: 12-16-2008, 09:58 AM
  3. Java actionlistener help
    By justsomeguy in forum AWT / Swing
    Replies: 1
    Last Post: 05-27-2008, 05:42 AM
  4. ActionListener interface
    By tsantana in forum New To Java
    Replies: 2
    Last Post: 03-30-2008, 10:24 PM
  5. error stack when I try to execute my code
    By paty in forum New To Java
    Replies: 1
    Last Post: 08-02-2007, 08:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •