Label to UIText

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

Label extends Component: be sure to see its changes.

Purpose and Usage

AFC's UIText extends the power of plain text in a number of ways. First, you have more control over alignment: instead of just left, center, and right, you have options like horizontal centering, vertical centering, corner alignment (like topleft or bottomright), and just top or bottom alignment. Second, you can hot-track a control: text objects are by default not hot-tracked, but instantiating them like

new UIText("foo", UIText.HOTTRACK & UIText.TOPLEFT);

formats the text accordingly. You also can specify that the control has no defining edge. Finally, UIText objects can be instantiated inside all types of different UIComponents to add new capabilities.

 

Porting

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

 

AWT Code AFC Code Comments
Label() or
Label(String) or
Label(String, int)
UIText() or
UIText(String) or
UIText(String, int)
 
CENTER CENTERED This is just replacing the style flag.
getText() getName()  
setText(String) setName(String)  
getAlignment() getFlags()  
setAlignment(int) setFlags(int)  

 

Unsupported Methods

A method in java.awt.Label is not directly supported in com.ms.ui.UIText. That method and suggested changes are described here.

 

AWT Code/Suggested AFC Code Comments
paramString()

getName() or getFlags()

These separate method calls allow you to get the exact information you want.