|
Rational Developer for Power Systems Software V7.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JLabel com.ibm.etools.iseries.ui.JFormattedLabel
public class JFormattedLabel
JFormattedLabel extends javax.swing.JLabel and implements com.ibm.etools.iseries.ui.JFormattedComponent. It is a label that allows you to define a field model, which can then specify a formatter, a validator, a keystroke verifier, and data attributes. Keystroke verifier has no effect on this component, because it is not a data entry type component. By default, JFormattedLabel uses AS400FieldModel which by default uses EditcodeEditwordFormatter, ComparisonRangeValidator, and the default data type is character, data length is 10, and decimal places is 0.
A formatter defines how a string can be formatted. Any data that is set using setUnformattedText method is formatted automatically and shown in the label in the format defined by the formatter. There is a EditcodeEditwordFormatter class that the AS/400 user can use. It allows you to select an editcode or set a user-defined editword. If none of the editcodes or editword meet the user requirements, users can create their own formatter class and set the JFormattedLabel's field model to use the user-defined formatter.
A validator is a class which can validate field values. Any data that is set in the field will be passed to a validator for validation prior to formatting and setting the text. Apart from the validator that validates the data, the JFormattedLabel itself also validates the data type, data length, and decimal places of the field. There is a ComparisonRangeValidator class which performs comparison validation or range validation. A comparison validation compares a field value in relation to another value. A range validation validates against a range of values. Again, if ComparisonRangeValidator does not meet the user requirements, users can write their own validator class and set the JFormattedLabel's field model to use the newly defined validator.
A keystroke verifier is a document class to that is used to verify keystroke entry. Since JFormattedLabel is not an entry type of component, anything that is set in the keystroke verifier field will be ignored. This property is only useful in JFormattedTextField and JFormattedComboBox.
DataAttributes is a used to hold field attributes such as auto advance flag (this flag is ignored in JFormattedLabel and is only used by JFormattedTextField and JFormattedComboBox), data type, data length, decimal point symbol, size of decimal places and background color when invalid entry occurs. By default, auto advance flag is set to false, data type is set to character, data length is 10, decimal point symbol will automatically pick up the locale value of a decimal point; decimal places is set to 0, and the reverseImageColor is set to java.awt.Color.red. These are bound properties, so you can change these values as you wish. Please note that the Attributes field must be an instance of com.ibm.etools.iseries.ui.DataAttributes; otherwise java.beans.PropertyVetoException will be thrown at run time. Property autoAdvance and reverseImageColor have no effect on a JFormattedLabel, whatever is set will be ignored.
Attributes dataAtt = new DataAttributes(DataAttributes.DATATYPE_NUMERIC, 10, 2, '.'); Formatter formatter = new EditcodeEditwordFormatter(dataAtt,'A', EditcodeEditwordFormatter.EDITCODEPARM_CURRENCY, null); Validator val = new ComparisonRangeValidator(dataAtt, ComparisonRangeValidator.VALIDITYTYPE_COMPARISON, ComparisonRangeValidator.COMPARISON_EQ, "1000.00", null, null); JFormattedLabel jfLabel = new JFormattedLabel("1000.00", null, SwingConstants.CENTER, new AS400FieldModel(dataAtt, formatter, val));
FieldModel
,
AS400FieldModel
,
DataAttributes
,
EditcodeEditwordFormatter
,
ComparisonRangeValidator
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JLabel |
---|
JLabel.AccessibleJLabel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
Copyright
|
Fields inherited from class javax.swing.JLabel |
---|
labelFor |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface com.ibm.etools.iseries.ui.JFormattedComponent |
---|
copyright |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JFormattedLabel()
Constructs a new JFormattedLabel. |
|
JFormattedLabel(Attributes dataAttributes,
Formatter formatter,
Validator validator,
Font font)
/** Creates a JFormattedLabel with the specified dataAttributes, formatter, validator and font. |
|
JFormattedLabel(FieldModel fm)
Creates a JFormattedLabel with the specified field model. |
|
JFormattedLabel(Icon image)
Creates a JFormattedLabel instance with the specified image. |
|
JFormattedLabel(Icon image,
int horizontalAlignment)
Creates a JLabel instance with the specified image and horizontal alignment. |
|
JFormattedLabel(String text)
JFormattedLabel constructor comment. |
|
JFormattedLabel(String text,
Icon icon,
int horizontalAlignment)
JFormattedLabel constructor comment. |
|
JFormattedLabel(String text,
Icon icon,
int horizontalAlignment,
FieldModel fm)
This method was created in VisualAge. |
|
JFormattedLabel(String text,
int horizontalAlignment)
JFormattedLabel constructor comment. |
Method Summary | |
---|---|
String |
convertInternalToUnformatted(String value)
Convert an internal value to an unformatted value. |
String |
convertUnformattedToInternal(String text)
Convert an unformatted value to an internal value. |
static String |
Copyright()
This method returns the copyright notice for this class. |
FieldModel |
getFieldModel()
|
String |
getInternalValue()
|
String |
getUnformattedText()
|
protected boolean |
isValueValid(String strText)
|
protected boolean |
isValueValidForNumeric(String strText)
|
void |
setFieldModel(FieldModel fm)
Sets the fieldModel property (com.ibm.etools.iseries.ui.FieldModel) value. |
void |
setInternalValue(String value)
The specified value will be validated by calling isValueValid method and by the validator, then it will be formatted by the formatter before setting it to the component. |
void |
setText(String text)
Defines the single line of text this component will display. |
void |
setUnformattedText(String text)
Defines the single line of text this component will validated and formatted prior to the display. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String Copyright
Constructor Detail |
---|
public JFormattedLabel()
public JFormattedLabel(Attributes dataAttributes, Formatter formatter, Validator validator, Font font)
dataAttributes
- The data attributes sucn as data type, data length, decimal places, etc.formatter
- The formatting used.validator
- The validation used.font
- The font in the label.public JFormattedLabel(FieldModel fm)
fm
- The field model for formatting and validating.public JFormattedLabel(String text)
text
- The text to be displayed by the label.public JFormattedLabel(String text, int horizontalAlignment)
text
- The text to be displayed by the label.horizontalAlignment
- One of the following constants defined in SwingConstants: LEFT, CENTER, or RIGHT.public JFormattedLabel(String text, Icon icon, int horizontalAlignment)
text
- The text to be displayed by the label.icon
- The image to be displayed by the label.horizontalAlignment
- One of the following constants defined in SwingConstants: LEFT, CENTER, or RIGHT.public JFormattedLabel(String text, Icon icon, int horizontalAlignment, FieldModel fm)
text
- The text to be displayed by the label.icon
- The image to be displayed by the label.horizontalAlignment
- One of the following constants defined in SwingConstants: LEFT, CENTER, or RIGHT.fm
- The field model for formatting and validating.public JFormattedLabel(Icon image)
image
- The image to be displayed by the label.public JFormattedLabel(Icon image, int horizontalAlignment)
image
- The image to be displayed by the label.horizontalAlignment
- One of the following constants defined in SwingConstants: LEFT, CENTER, or RIGHT.Method Detail |
---|
public String convertInternalToUnformatted(String value)
value
- java.lang.String
public String convertUnformattedToInternal(String text)
value
- java.lang.String
public static String Copyright()
public FieldModel getFieldModel()
getFieldModel
in interface JFormattedComponent
public String getInternalValue()
public String getUnformattedText()
protected boolean isValueValid(String strText)
protected boolean isValueValidForNumeric(String strText)
public void setFieldModel(FieldModel fm)
setFieldModel
in interface JFormattedComponent
fm
- The new value for the property.getFieldModel()
public void setInternalValue(String value) throws InvalidDataException
value
- java.lang.String
InvalidDataException
getInternalValue()
public void setText(String text)
setText
in class JLabel
text
- java.lang.Stringpublic void setUnformattedText(String text) throws InvalidDataException
text
- java.lang.String
InvalidDataException
|
Rational Developer for Power Systems Software V7.6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |