I am in the throws of passing parameters to an applet using getParameter method. I am completely new to HTML tags.
Here is the code:
No parameter is being passed to the applet.import java.awt.*; import java.applet.*; /* * <applet code="ParamDemo" width=100 height=80> <param name=fontName value="Courier"> <param name=fontSize value="14"> <param name=leading value="2"> <param name=accountEnabled value=true> </applet> */ //use ParamDemo public class ParamDemo extends Applet { String fontName; int fontSize; float leading; boolean active; public void start(){ String param; fontName=getParameter("fontName"); if (fontName==null) fontName="Font Not Found"; param=getParameter("fontsize"); try{ if (param !=null) fontSize=Integer.parseInt(param); else fontSize=0; }catch(NumberFormatException e){ fontSize=-1; } param=getParameter("leading"); try{ if (param !=null) leading=Float.valueOf(param).floatValue(); else fontSize=0; }catch(NumberFormatException e){ leading=-1; } param=getParameter("accountEnabled"); if(param!=null) active=Boolean.valueOf(param).booleanValue(); } public void paint(Graphics g){ g.drawString("Fontname: "+fontName, 0, 10); g.drawString("FontSize: "+fontSize, 0, 26); g.drawString("leading "+leading, 0, 42); g.drawString("AccoumtActive "+active, 0, 58); } }
I tried debugging the code but param variable is always set to null. What's wrong?