Many times we have to run Swing Demo, available online or JDK's own Swing Demo and Java game, there are many applets, how do you usually run? Open a time-consuming and eating memory IDE? Still write HTML to load Applet? Still hand writing the main method? Here is an idea to develop an applet running environment. You can just run the most simple example every time, just instantiate the applet, call the init method, you can meet the needs of our run Demo, if you need more Function, refer to the Applet specification to add more processing to import java.awt. *; Import java.awt.event. *; Import javax.swing. *; Public class runapplet {public static void main (string args []) THROWS EXCEPTION {IF (args == null) return;
Class CLS = Class.Forname (Args [0]); Object O = CLS.NEWINSTANCE (); CLS.GetMethod ("init", null); jframe frame = new jframe ("applet viewer" Frame.getContentPane (). Add (panel) o); frame.setsize (500, 500); frame.show ();
Frame.addwindowlistener (new windowadapter () {public void windowclosing (java.awt.event.windowevent e) {system.exit (0);};
}};
Write the RunApt.bat file, the content is set as the following RUNAPPLET.CLASS to ClassPath in the set path =% path%; E: / myToolsset ClassPath =% classpath%; E: / MyTools D: /j2sdk1.4.1/bin/java.exe Runapplet % 1Pause .. Run the runapt command, run the applet directly Runapt HelloWorldapplet can be configured to editplus, and integrate the runapt.bat command to editplus, refer to my article: EditPlus integrated development environment configuration (configuration compilation environment)