Applet Parameters
1. What Are Parameters? (beginner)
Params = settings from HTML to applet (no recompile to change name/color!). Like function args, but from web page! <param name="msg" value="hi"> → getParameter("msg") → "hi"!
2. Code — HTML + Java (exam pair!)
<!-- page.html -->
<applet code="Hi.class" width="300" height="100">
<param name="msg" value="Hello Web!">
<param name="size" value="20">
</applet>
3. Rules (traps!)
- ALL params are String (parse numbers yourself!).
- Missing →
null(check! else NPE!). getParameterininit()(once! not paint!).
4. Modern Twin (viva!)
Applets dead, but SAME idea lives: command args (args[]), properties (-Dmsg=hi), env vars, config files!
5. Exam Points
- HTML +
getParameterprogram — 5-7 marks, frequent. - String-only + null-check — 3 marks, frequent.