Results 1 to 3 of 3
- 03-19-2011, 02:52 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 22
- Rep Power
- 0
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"); outBuff.close(); } 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 :)
- 03-19-2011, 04:20 AM #2
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)
db
- 03-19-2011, 06:17 PM #3
Member
- Join Date
- Mar 2011
- Posts
- 22
- Rep Power
- 0
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
-
For some reason, my GUI is not recognizing multiple action listeners for buttons.
By JavaStudent1990 in forum New To JavaReplies: 8Last Post: 08-10-2010, 02:59 AM -
Creating a GUI events with action listeners
By sidd0123 in forum AWT / SwingReplies: 8Last Post: 04-02-2010, 11:32 PM -
JOptionPane, action listeners, and the Enter key.
By DigitalMan in forum AWT / SwingReplies: 5Last Post: 01-26-2010, 02:51 AM -
JRE 1.5.0_6 version issue in java Applets
By raj_java in forum Java AppletsReplies: 1Last Post: 02-21-2009, 03:25 AM -
Action Event and Listeners
By lost1 in forum New To JavaReplies: 3Last Post: 11-14-2007, 04:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks