Signature applet practice
Make an applet to create a file locally. I. Environment: Windows XP, IIS, JDK1.4.1_02. II. Server-side procedure: 1.c: / applets Create a Test.htm file, the content is as follows:
2.C: / Applets Create a Test Directory, create a TestApplet.java file in this directory, as follows:
Package test;
Import java.io. *; import java.applet. *; import javax.swing. *; import java.awt.event. *;
public class TestApplet extends Applet {public void init () {JButton button = new JButton ( "Create a file"); button.addActionListener (new ActionListener () {public void actionPerformed (ActionEvent evt) {File file = new File ( "c : //a.txt "); try {file.createnewfile (); JOPANE.SHOWMESSAGEDIALOG (NULL," Successfully created file c: //a.txt "," message ", joptionpane.information_message);} catch (Exception EX ) {JOPANE.SHOWMESSAGEDIALOG (NULL, EX.GETMESSAGE (), "Error", JOPANE.ERROR_MESSAGE);}}}; add (button);}}