Results 1 to 3 of 3
  1. #1
    aadem is offline Member
    Join Date
    Mar 2011
    Rep Power

    Default Applets issue with Action Listeners

    Hello everyone! Ive been learning quite a bit about swing gui programming lately, and decided to try and use that knowledge to throw together a quick applet. Its a mock username and password login box that writes the username and password from the text fields to a file. I insert this code for an action listener for a button named okButton

    Java Code:
    	okButton.addActionListener(new ActionListener() {
    		public void actionPerformed(ActionEvent e) {
    		    try {
    		    FileWriter outFile = new FileWriter("test.txt", true);
    		    BufferedWriter outBuff = new BufferedWriter(outFile);
    		    String getpw = pwTxt.getText();
    		    String getuname = unameTxt.getText();
    		    outBuff.write("\nUsername:" + getuname + "\n");
    		    catch (IOException exio) {
    			System.err.println("I/O Error");

    its erroring out with an AWT queue error permission denied.
    Me and another programmed a sip alg detector applet for our job, and that was in an applet. I remember to get over windnows permission problems we had to sign that applet is that what i need to do here? I wasnt the one who did that part so i never learned how to do it otherwise id just try and see :)

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power


    Applets run in a sandboxed environment and aren't allowed to access the local file system unless trusted. As your goal is to practice GUIs and writing to a file, rewrite the GUI as an application instead of an Applet and you're good to go.

    If you need some guidance in doing that, refer to Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)


  3. #3
    aadem is offline Member
    Join Date
    Mar 2011
    Rep Power

    Default ty!

    Thank you so much for the response DB! I appreciate it. I actually already have quite a few programs written as applications which successfully manage files on my local filesystem. This project was essentially "I wonder if i can make my program here into an applet"

    Hehe but since the time of this post, i actually have learned the method for signing an applet and am going to do that now. Ill mark this as solved if it works :)

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2010, 02:59 AM
  2. Creating a GUI events with action listeners
    By sidd0123 in forum AWT / Swing
    Replies: 8
    Last Post: 04-02-2010, 11:32 PM
  3. JOptionPane, action listeners, and the Enter key.
    By DigitalMan in forum AWT / Swing
    Replies: 5
    Last Post: 01-26-2010, 02:51 AM
  4. JRE 1.5.0_6 version issue in java Applets
    By raj_java in forum Java Applets
    Replies: 1
    Last Post: 02-21-2009, 03:25 AM
  5. Action Event and Listeners
    By lost1 in forum New To Java
    Replies: 3
    Last Post: 11-14-2007, 04:26 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