Java Input Routines


inParam.class inParam.java


The following is a small set of utilities to reduce some of the coding needed to input Java variables. This includes inputting: a boolean variable; a string variable; an integer variable; a floating poing number; a Color (very handy - saves a lot of excess coding) variable; and FONT parameters (Font Name, Style, and Size).

  • "getBoolParam(name1,def_value)" returns a boolean corresponding to the parameter tag with name, "name1". The parameter "def_value" is the default value used if the the parameter is not input or is unreadable. You may use "true" (case insensitive) or "1" to indicate true. Similarly, "false" or "0" indicate "false.

  • "getStringParam(name1,def_value)" returns the String that corresponds to the parameter tag with the name "name1". The parameter "def_value" is the default string to use if the parameter is not input or is unreadable. Although, "def_value" must be among the function arguments it may be null.

  • "getIntParam(name1,def_value,min, max)" returns the integer that corresponds to the parameter tag with the name "name1". The parameter "def_value" is the default value to use if the parameter is not input, is unreadable, or is out of the range defined by "min" and "max". "min" and "max" are the minimum and maximum values allowed for this variable.

  • "getFloatParam(name1,def_value,min, max)" returns the floating point number that corresponds to the parameter tag with the name "name1". The parameter "def_value" is the default value to use if the parameter is not input, is unreadable, or is out of the range defined by "min" and "max". "min" and "max" are the minimum and maximum values allowed for this variable.

  • "getColorParam(name1,def_value)" returns the "color" variable corresponding to the parameter tag with name, "name1". The parameter "def_value" is the default color used if the the parameter is not input or is unreadable. Input values for the colors may be input as (case insensitive) names (black, blue, cyan, darkGray, Gray, lightGray, green, magenta, orange, pint, red, white, or yellow) or as a numeric triad corresponding to red, green, and blue. The triad may be delimited by either colons, commas, or periods (or any combination of them).
    When I checked this routine I noticed a problem with the default. It presently always defaults to light gray. This will be corrected shortly.

  • "getFontParam(name1,def_name,style1, def_style, size1, def_size)": This routine checks 3 input lines. It returns the Font corresponding to the parameter tag with the name, "name1"; the font style corresponding to the integer gotten from the tag with the name, style1; and the size corresponding to the parameter tag with the name, size1. The parameters "def_name, def_style, and def_size" are the default values to use if the parameters are not input or are unreadable. Style is input as an integer with "0" indicating plain, "1" indicating bold, "2" indicating italic, and "3" indicating bold-italic.



  • Since the the utilities are rather ubiquitous in use, they have been compiled as a package. Examples of the use of its use may be found in the other Java codes. If you think of any unusual ways to use these routines or have any suggestions for additional routines, drop me a line.