HiRISE

HiRISE.HiPlan.HiWeb
Class RangeVerifier

java.lang.Object
  extended by javax.swing.InputVerifier
      extended by HiRISE.HiPlan.HiWeb.RangeVerifier

public class RangeVerifier
extends InputVerifier

A Swing InputVerifier that will only accept input between a range of numbers for a subclass of JTextComponent. The range is inclusive.

Version:
1.6
Author:
Guy McArthur - UA/PIRL

Field Summary
static Color ALERT_COLOR
          The text color for text components containing out-of-range text.
static String ID
          Class identification name with source code version and date.
 
Constructor Summary
RangeVerifier(double min, double max)
          Creates a new RangeVerifier with the inclusive range from min to max.
RangeVerifier(double min, double max, boolean allowBlanks)
          Creates a new ranger verifier with the inclusive range from min to max.
 
Method Summary
 boolean allowBlanks()
           
 void allowBlanks(boolean allowBlanks)
           
 double max()
           
 void max(double max)
           
 double min()
           
 void min(double min)
           
 boolean shouldYieldFocus(JComponent input)
          Tests whether the component should yield focus.
 boolean verify(JComponent input)
          Verifies that the value for the component is within the allowed range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class identification name with source code version and date.

See Also:
Constant Field Values

ALERT_COLOR

public static final Color ALERT_COLOR
The text color for text components containing out-of-range text.

Constructor Detail

RangeVerifier

public RangeVerifier(double min,
                     double max,
                     boolean allowBlanks)
Creates a new ranger verifier with the inclusive range from min to max. Blank values are allowed if allowBlanks is true; otherwise they are not.

Parameters:
min - the minimum allowed value.
max - the maximum allowed value.
allowBlanks - if true, blanks are allowed in the input to be verified.

RangeVerifier

public RangeVerifier(double min,
                     double max)
Creates a new RangeVerifier with the inclusive range from min to max. Blanks are not allowed in the test input.

Parameters:
min - the lowest allowed value.
max - the highest allowed value.
Method Detail

min

public double min()

min

public void min(double min)

max

public double max()

max

public void max(double max)

allowBlanks

public boolean allowBlanks()

allowBlanks

public void allowBlanks(boolean allowBlanks)

verify

public boolean verify(JComponent input)
Verifies that the value for the component is within the allowed range. The component should be a subclass of JTextComponent; if not, the verification fails and the method returns false.

Specified by:
verify in class InputVerifier
Parameters:
input - the test component.
Returns:
true if the value is allowed; false otherwise or if the input is not a JTextComponent.

shouldYieldFocus

public boolean shouldYieldFocus(JComponent input)
Tests whether the component should yield focus. If the component should not, its foreground (text) color is set to ALERT_COLOR and the system beep sounds; if it should, the foreground color is set to null, such that the component inherits its foreground color from its parent.

The test is conducted via a call to verify(javax.swing.JComponent).

Overrides:
shouldYieldFocus in class InputVerifier
Parameters:
input - the test component.
Returns:
true if the component should yield the focus; false otherwise.

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona