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

Variable Index

 o autoNumberOfCharacters
Determines whether maxNumberOfCharacters should be based on the size of the text field
 o errorMessage
The error message that should be displayed in the case of a parsing error
 o mathValue
The mathematical value represented in the text field
 o maxNumberOfCharacters
The maximum number of characters (not counting the decimal point) to be displayed

Constructor Index

 o EDU.emporia.mathbeans.MathTextField()

Method Index

 o adjustCharacterLength(int)
Adjusts the number of characters to be displayed to accommodate the size
 o getMathValue()
Returns the mathematical value corresponding to the String displayed in the text field
 o getMaxNumberOfCharacters()
Gets the maximum number of characters (not counting the decimal point) that will be displayed in the text field.
 o 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
 o main(String[])
 o processFocusEvent(FocusEvent)
Method to handle focus events.
 o 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
 o setBounds(int, int, int, int)
Overridden method to adjust the number of characters displayed when the text field is resized.
 o setBounds(Rectangle)
Overridden method to adjust the number of characters displayed when the text field is resized.
 o setMathValue(double)
Sets the mathematical value corresponding to be displayed in the text field
 o setMaxNumberOfCharacters(int)
Sets the maximum number of characters (not counting the decimal point) that will be displayed in the text field.
 o setSize(int, int)
Overridden method to adjust the number of characters displayed when the text field is resized.
 o setSize(Dimension)
Overridden method to adjust the number of characters displayed when the text field is resized.
 o setText(String)
Overrides the setText method of JTextField to parse an arithmetic expression.

Variables

 o autoNumberOfCharacters
protected boolean autoNumberOfCharacters
Determines whether maxNumberOfCharacters should be based on the size of the text field

 o errorMessage
protected boolean errorMessage
The error message that should be displayed in the case of a parsing error

 o mathValue
protected double mathValue
The mathematical value represented in the text field

 o maxNumberOfCharacters
protected int maxNumberOfCharacters
The maximum number of characters (not counting the decimal point) to be displayed

Constructors

 o MathTextField
public MathTextField()

Methods

 o adjustCharacterLength
public void adjustCharacterLength(int w)
Adjusts the number of characters to be displayed to accommodate the size

Parameters:
w - The width in pixels
 o getMathValue
public double getMathValue()
Returns the mathematical value corresponding to the String displayed in the text field

Returns:
The value
 o 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.
 o 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.
 o main
public static void main(String[] argv)
 o 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
 o 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.
 o 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
 o 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
 o 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
 o 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.
 o 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
 o 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
 o 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