MenuItem to UIText

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

MenuItem extends MenuComponent: be sure to see its changes.

Purpose and Usage

AWT's MenuItem class only allows you to convert Strings into menu items. The AFC equivalent of doing this is to create UIText items and add those to menus instead. So instead of

Menu myMenu = new Menu();
myMenu.add(new MenuItem("First Item"));

you would have

UIMenuList myMenu = new UIMenuList;
myMenu.add(new UIText("First Item"));

This is a direct change: AFC, though, provides you many other options to add to a menu. Any UIComponent (like UIItem, which combines an image and text, and any type of UIButton) can be added to a UIMenuList. See the documentation for more information on those classes.

 

Porting

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

 

AWT Code AFC Code Comments
MenuItem() or
MenuItem(String) or
MenuItem(String, MenuShortcut)
UIText() or
UIText(String)
Shortcuts are implemented by default in AFC as incremental-type searches.
disable() setEnabled(false) Deprecated in AWT 1.1
enable() setEnabled(true) Deprecated in AWT 1.1
enable(boolean) setEnabled(boolean) Deprecated in AWT 1.1
getLabel() getName()  
getActionCommand() getName() In AFC, the name is the action command sent when an event occurs.

 

Unsupported Methods

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

 

AWT Code/Suggested AFC Code Comments
deleteShortcut()

(no suggestions)

Shortcuts are implemented by default in AFC as an incremental-type search.
getShortcut()

(no suggestions)

Shortcuts are implemented by default in AFC as an incremental-type search.
paramString()

getName(), etc.

Call the specific getXXX function you need.