|
NOTA: La traducción de esta documentación es un esfuerzo personal y voluntario, no es un documento oficial de Sun Microsystems
ni Oracle ni está patrocinado por ninguna de estas empresas. Los documentos originales (en inglés) están disponibles en:
http://java.sun.com/docs/books/tutorial/.
Dirija cualquier comentario, petición, felicitación, etc. a tutorialesjava_@RROBA_codexion.com. |
Si desea ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesita que se traduzca algĂșn capĂtulo en concreto puede realizar una donación directa mediante Paypal:
|
Applets use theApplet getParametermethod to get user-specified values for applet parameters. ThegetParametermethod is defined as follows:public String getParameter(String name)Your applet might need to convert the string that
getParameterreturns into another form, such as an integer. Thejava.langpackage provides classes such as Integer that you can use to help with converting strings to primitive types. Here's an example of converting a parameter's value into an integer:Note that if the user doesn't specify a value for theint requestedWidth = 0; . . . String windowWidthString = getParameter("WINDOWWIDTH"); if (windowWidthString != null) { try { requestedWidth = Integer.parseInt(windowWidthString); } catch (NumberFormatException e) { //Use default width. } }WINDOWWIDTHparameter, the above code uses a default value of 0, which the applet interprets as "use the window's natural size." It's important that you supply default values wherever possible.Besides using the
getParametermethod to get values of applet-specific parameters, you can also usegetParameterto get the values of attributes of the applet's<APPLET>tag. See Using the applet Tag for a list of<APPLET>tag attributes.