You can customize your applets by providing parameters at runtime in <param>. But it is a good practice to always provide default values, when specific values for parameters are not provided.
You can do this by checking for null values and/or proper type checking (if
you expect numeric or date values). Here is the code:
public class MyApplet extend Applet {
public void init(){
// Get the Parameter
String frameTitle = getParameter("FRAME_TITLE");
// Check for Null
if (frameTitle == null) {
// Provide Default value
frameTitle = "Frame to Test Parameters";
}
String frameWidthString = getParameter("FRAME_WIDTH");
int frameWidthInt = 0;
try{
frameWidthInt = Integer.parseInt(frameWidthString);
} catch(Exception ex){
// Catch Exception if frameWidthString is null or invalid value
// Default value
frameWidthInt = 100;
}
String frameHeightString = getParameter("FRAME_WIDTH");
int frameHeightInt = 0;
try{
frameHeightInt = Integer.parseInt( frameHeightString );
} catch(Exception ex){
// Provide Default Value
frameHeightString = 100;
}
Frame f = new Frame(frameTitle);
f.setSize(frameWidthInt,frameHeightString);
f.show();
}
}