Class EDU.emporia.mathbeans.MathTextField
All Packages Class Hierarchy This Package Previous Next Index
Class EDU.emporia.mathbeans.MathTextField
Object
|
+----Component
|
+----Container
|
+----JComponent
|
+----JTextComponent
|
+----JTextField
|
+----EDU.emporia.mathbeans.MathTextField
- public class MathTextField
- extends JTextField
A text field that can be used to display numerical data for mathematical purposes.
It can parse common arithmetic expressions
- Version:
- 1.0
- Author:
- Joe Yanik
- Since:
- 7/6/00
-
autoNumberOfCharacters
- Determines whether maxNumberOfCharacters should be based on the size of
the text field
-
errorMessage
- The error message that should be displayed in the case of a parsing
error
-
mathValue
- The mathematical value represented in the text field
-
maxNumberOfCharacters
- The maximum number of characters (not counting the decimal point) to
be displayed
-
EDU.emporia.mathbeans.MathTextField()
-
-
adjustCharacterLength(int)
- Adjusts the number of characters to be displayed to accommodate the size
-
getMathValue()
- Returns the mathematical value corresponding to the String displayed in
the text field
-
getMaxNumberOfCharacters()
- Gets the maximum number of characters (not counting the decimal point)
that will be displayed in the text field.
-
isAutoNumberOfCharacters()
- Returns the value of autoNumberOfCharacters which determines whether or not
the number of characters should be determined by user preference or
by the width of the text field
-
main(String[])
-
-
processFocusEvent(FocusEvent)
- Method to handle focus events.
-
setAutoNumberOfCharacters(boolean)
- Sets the value of autoNumberOfCharacters which determines whether or not
the number of characters should be determined by user preference or
by the width of the text field
-
setBounds(int, int, int, int)
- Overridden method to adjust the number of characters displayed when
the text field is resized.
-
setBounds(Rectangle)
- Overridden method to adjust the number of characters displayed when
the text field is resized.
-
setMathValue(double)
- Sets the mathematical value corresponding to be displayed in
the text field
-
setMaxNumberOfCharacters(int)
- Sets the maximum number of characters (not counting the decimal point)
that will be displayed in the text field.
-
setSize(int, int)
- Overridden method to adjust the number of characters displayed when
the text field is resized.
-
setSize(Dimension)
- Overridden method to adjust the number of characters displayed when
the text field is resized.
-
setText(String)
- Overrides the setText method of JTextField to parse an arithmetic
expression.
autoNumberOfCharacters
protected boolean autoNumberOfCharacters
- Determines whether maxNumberOfCharacters should be based on the size of
the text field
errorMessage
protected boolean errorMessage
- The error message that should be displayed in the case of a parsing
error
mathValue
protected double mathValue
- The mathematical value represented in the text field
maxNumberOfCharacters
protected int maxNumberOfCharacters
- The maximum number of characters (not counting the decimal point) to
be displayed
MathTextField
public MathTextField()
adjustCharacterLength
public void adjustCharacterLength(int w)
- Adjusts the number of characters to be displayed to accommodate the size
- Parameters:
- w - The width in pixels
getMathValue
public double getMathValue()
- Returns the mathematical value corresponding to the String displayed in
the text field
- Returns:
- The value
getMaxNumberOfCharacters
public int getMaxNumberOfCharacters()
- Gets the maximum number of characters (not counting the decimal point)
that will be displayed in the text field. Numerical data will be
formatted to fit into that space. Must be at least 6.
- Returns:
- The maximum number of characters (not counting the decimal point) that
will be displayed.
isAutoNumberOfCharacters
public boolean isAutoNumberOfCharacters()
- Returns the value of autoNumberOfCharacters which determines whether or not
the number of characters should be determined by user preference or
by the width of the text field
- Returns:
- True if the maximum number of characters will be based on the width of
the text field. False if it will be based on the value of
maxNumberOfCharacters.
main
public static void main(String[] argv)
processFocusEvent
public void processFocusEvent(FocusEvent e)
- Method to handle focus events. It tries to parse the expression when the
focus is lost and selects the text when the focus is gained
- Parameters:
- e - a focus event
- Overrides:
- processFocusEvent in class JComponent
setAutoNumberOfCharacters
public void setAutoNumberOfCharacters(boolean autoNumberOfCharacters)
- Sets the value of autoNumberOfCharacters which determines whether or not
the number of characters should be determined by user preference or
by the width of the text field
- Parameters:
- autoNumberOfCharacters - If true the maximum number of characters will be based on the width of
the text field. Otherwise it will be based on the value of
maxNumberOfCharacters.
setBounds
public void setBounds(int a,
int b,
int c,
int d)
- Overridden method to adjust the number of characters displayed when
the text field is resized.
- Parameters:
- a - x-coordinate
- b - y-coordinate
- c - with
- d - height
- Overrides:
- setBounds in class Component
setBounds
public void setBounds(Rectangle a)
- Overridden method to adjust the number of characters displayed when
the text field is resized.
- Parameters:
- a - The rectangle used in resizing
- Overrides:
- setBounds in class Component
setMathValue
public void setMathValue(double value)
- Sets the mathematical value corresponding to be displayed in
the text field
- Parameters:
- value - The value to be displayed
setMaxNumberOfCharacters
public void setMaxNumberOfCharacters(int maxNumberOfCharacters)
- Sets the maximum number of characters (not counting the decimal point)
that will be displayed in the text field. Numerical data will be
formatted to fit into that space. Must be at least 6.
- Parameters:
- maxNumberOfCharacters - The maximum number of characters (not counting the decimal point) that
will be displayed. Any value smaller than 6 will be ignored.
setSize
public void setSize(int a,
int b)
- Overridden method to adjust the number of characters displayed when
the text field is resized.
- Parameters:
- a - width
- b - height
- Overrides:
- setSize in class Component
setSize
public void setSize(Dimension a)
- Overridden method to adjust the number of characters displayed when
the text field is resized.
- Parameters:
- a - Dimension used inresizing
- Overrides:
- setSize in class Component
setText
public void setText(String s)
- Overrides the setText method of JTextField to parse an arithmetic
expression.
- Parameters:
- s - The text to be parsed
- Overrides:
- setText in class JTextComponent
All Packages Class Hierarchy This Package Previous Next Index