How can I easily provide default values for when applet parameters are not specified?

John Zukowski

Here's a helper method that you can use to do that:

import java.applet.*;

public class AppletUtils {
  private AppletUtils() {}

  public static String getParameter(
      Applet applet, String key, String keyDefault) {

    String value = applet.getParameter(key);

    return (value == null) ? keyDefault : value;

  }
}
Here's how to call:
  String var = AppletUtils.getParameter(this, "name", "Jaeger");
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact