天天看点

JavaScript 与applet信息交互

????

? applet??浠讹?Applet1.java ?

? //public ? String ? getAppletInfo()??javascript涓?灏?瑕?璋??ㄧ???规?锛?缂?璇????跺??璁板?甯??? ? ?

? ?

? package ? manager_test; ?

? ?

? import ? java.awt.*; ?

? import ? java.awt.event.*; ?

? import ? java.applet.*; ?

? import ? javax.swing.*; ?

? ?

? public ? class ? Applet1 ? extends ? JApplet ? { ?

? ? ? boolean ? isStandalone ? = ? false; ?

? ? ? String ? var0; ?

? ? ? ?

? ? ? public ? String ? getParameter(String ? key, ? String ? def) ? { ?

? ? ? ? ? return ? isStandalone ? ? ? System.getProperty(key, ? def) ? : ?

? ? ? ? ? ? ? (getParameter(key) ? != ? null ? ? ? getParameter(key) ? : ? def); ?

? ? ? } ?

? ?

? ? ? ?

? ? ? public ? Applet1() ? { ?

? ? ? } ?

? ? ? ?

? ? ? public ? void ? init() ? { ?

? ? ? ? ? try ? { ?

? ? ? ? ? ? ? var0 ? = ? this.getParameter("param0", ? ""); ?

? ? ? ? ? } ?

? ? ? ? ? catch(Exception ? e) ? { ?

? ? ? ? ? ? ? e.printStackTrace(); ?

? ? ? ? ? } ?

? ? ? ? ? try ? { ?

? ? ? ? ? ? ? jbInit(); ?

? ? ? ? ? } ?

? ? ? ? ? catch(Exception ? e) ? { ?

? ? ? ? ? ? ? e.printStackTrace(); ?

? ? ? ? ? } ?

? ? ? } ?

? ? ? ?

? ? ? private ? void ? jbInit() ? throws ? Exception ? { ?

? ? ? ? ? this.setSize(new ? Dimension(400,300)); ?

? ? ? } ?

? ? ? ?

? ? ? public ? String ? getAppletInfo() ? { ?

? ? ? System.out.println ? ("Applet1"); ?

? ? ? ? ? return ? "Applet ? Information"; ?

? ? ? } ?

? ? ? ?

? ? ? public ? String[][] ? getParameterInfo() ? { ?

? ? ? ? ? String[][] ? pinfo ? = ?

? ? ? ? ? ? ? { ?

? ? ? ? ? ? ? {"param0", ? "String", ? ""}, ?

? ? ? ? ? ? ? }; ?

? ? ? ? ? return ? pinfo; ?

? ? ? } ?

? ?

? ? ? //static ? initializer ? for ? setting ? look ? & ? feel ?

? ? ? static ? { ?

? ? ? ? ? try ? { ?

? ? ? ? ? ? ? //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); ?

? ? ? ? ? ? ? //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); ?

? ? ? ? ? } ?

? ? ? ? ? catch(Exception ? e) ? { ?

? ? ? ? ? } ?

? ? ? } ?

? } ?

? ?

? jsp??浠?pplet1.jsp ?

? ?

? <html> ?

? <head> ?

? <title>Untitled ? Document</title> ?

? <meta ? http-equiv="Content-Type" ? content="text/html; ? charset=gb2312"> ?

? </head> ?

? ?

? <SCRIPT ? language=JavaScript> ?

? function ? PutOut() ?

? { ?

? window.document.MyApplet.getAppletInfo(); ?

? } ?

? </SCRIPT> ?

? ?

? <body ? bgcolor="#FFFFFF"> ?

? <table ? width="90%" ? ? cellspacing="5" ? cellpadding="5"> ?

? ? ? <tr> ?

? ? ? ? ? <td ? colspan="4"> ?

? <object ? id="MyApplet" ? classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ? width="580" ? height="420" ? name="applet" ? ?

? ? ? ? ? codebase="/plug-in/j2re-1_3_1_01-win-i.exe#Version=1,3,1,1"> ?

? ? ? ? ? <param ? name="code" ? ? ? value="manager_test.Applet1.class"> ?

? <param ? name="type" ? ? ? value="application/x-java-applet;version=1.3"> ?

? <!--<param ? name='archive' ? ? ? value='SystemStateapplet.jar'>--> ?

? ? ? ? ? </object></td> ?

? ? ? </tr> ?

? </table> ?

? <p>&nbsp;</p> ?

? <p> ?

? ? ? <input ? type="submit" ? name="Submit" ? value="Submit" ? onClick=PutOut()> ?

? </p> ?

? </body> ?

? </html>??

继续阅读