Hi I need help plese, could any one tell me how to Pass in avirable from the HTML file using the PARAM tag. Also, pass in parameters to specify the font and colour of the text that is drawn to the screen. I did creat an Applet to demostrate it but doesn't displeay the the name said Hello null insteat of hello Ali.
Code:public class DrawName extends java.applet.Applet { String name; Color color; Font font; /** Initialization method that will be called after the applet is loaded * into the browser. */ public void init() { name = getParameter("name"); //color= getParameter("color"); //font= getParameter("font"); } // TODO overwrite start(), stop() and destroy() methods public void paint(Graphics g) { //g.setColor(color); g.drawString("Hello" + name ,50,30); } }HTML Code:<HTML> <HEAD> <TITLE>Applet HTML Page</TITLE> </HEAD> <BODY> <H3><HR WIDTH="100%">Applet HTML Page<HR WIDTH="100%"></H3> <P> <APPLET codebase="classes" code="DrawName.class" width=350 height=200> <param name="name" value="Ali"> </APPLET> </P> <HR WIDTH="100%"><FONT SIZE=-1><I>Generated by NetBeans IDE</I></FONT> </BODY> </HTML>




Reply With Quote