TextField to UIEdit

To convert from AWT to AFC, instances of java.awt.TextField should be transformed into instances of com.ms.ui.UIEdit.

TextField extends TextComponent: be sure to see its changes.

Purpose and Usage

TextField provides a single-line text input component. UIEdit provides for both single-line and multi-line input components, so to restrict to a single line, simply call setSingleLine(true) on your UIEdit object. To specify a preferred or minimum size for a UIEdit control, you must create a new class which extends UIEdit and overrides the getPreferredSize() or getMinimumSize() method.

UIEdit extends UIDrawText, a class that provides many new options: you can set alignments, foreground and background colors, and many others. See the documentation for UIDrawText for many more options.

Porting

This is the set of changes you need to make to port all TextField methods to UIEdit methods. Any method not listed here or below does not need to be changed.

 

AWT Code AFC Code Comments
TextField() or
TextField(String)
object = new UIEdit(); // or UIEdit(String)
object.setSingleLine(true);
 
TextField(int) or
TextField(String, int)
object = new UIEdit(); // or UIEdit(String)
object.setMaxBufferSize(int);
 
getEchoChar() getPasswordChar()  
getColumns() getMaxBufferSize()  
minimumSize() getMinimumSize() Deprecated in AWT 1.1
setEchoChar(char) setPasswordChar(char)  
setEchoCharacter(char) setPasswordChar(char) Deprecated in AWT 1.1
setColumns() setMaxBufferSize()  

 

Unsupported Methods

Some methods in java.awt.TextField are not directly supported in com.ms.ui.UIEdit. Those methods and suggested changes are described here.

 

AWT Code/Suggested AFC Code Comments
echoCharIsSet()

(no suggestions)

 
getMinimumSize(int)

(no suggestions)

 
getPreferredSize(int)

(no suggestions)

 
minimumSize(int)

(no suggestions)

Deprecated in AWT 1.1
paramString()

getName(), etc.

Use the appropriate getXXX function to gather the information you need.
preferredSize(int)

(no suggestions)

Deprecated in AWT 1.1