To convert from AWT to AFC, instances of java.awt.TextArea should be transformed into instances of com.ms.ui.UIEdit.
TextArea extends TextComponent: be sure to see its changes.
AWT's TextArea class implements multi-line textual user input components. AFC's UIEdit is a generic edit box which can be either single-line or multi-line. 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 has some different defaults than TextArea: first, it does not add scroll bars automatically, and so if you would like scroll bars, a UIEdit object needs to be dropped into a UIScrollViewer. Also, while TextArea starts with a white background, UIEdit's is grey. So to mimic a TextArea exactly, your code would be like
UIEdit textBox = new
UIEdit();
textBox.setBackground(FxColor.white);
add(new UIScrollViewer(textBox));
UIEdit extends UIDrawText, a class that provides many new options: you can set alignments, foreground and background colors, word wrapping, and many others. See the documentation for UIDrawText for many more options.
This is the set of changes you need to make to port all TextArea methods to UIText methods. Any method not listed here or below does not need to be changed.
AWT Code | AFC Code | Comments |
TextArea() or TextArea(String) |
UIEdit or UIEdit(String) |
|
insertText(String, int) | insert(String, int) | Deprecated in AWT 1.1 |
minimumSize() | getMinimumSize() | Deprecated in AWT 1.1 |
preferredSize() | getPreferredSize() | Deprecated in AWT 1.1 |
Some methods in java.awt.TextArea are not directly supported in com.ms.ui.UIText. Those methods and suggested changes are described here.
AWT Code/Suggested AFC Code | Comments |
TextArea(int,
int) UIEdit(),
plus |
in UIEdit, you cannot manipulate the number of visible rows or columns: you can make changes in UIScrollViewer to do that. See documentation. |
TextArea(String,
int, int) UIEdit(String),
plus |
in UIEdit, you cannot manipulate the number of visible rows or columns: you can make changes in UIScrollViewer to do that. See documentation. |
TextArea(String, int,
int, int) UIEdit(String),
plus |
in UIEdit, you cannot manipulate the number of visible rows or columns: you can make changes in UIScrollViewer to do that. See documentation. |
getColumns() (see UIScrollViewer) |
UIEdit has no control over the visible number of columns: you can make changes in UIScrollViewer to do that. |
getMinimumSize(int,
int) (no suggestions) |
|
getPreferredSize(int,
int) (no suggestions) |
|
getRows() (see UIScrollViewer) |
UIEdit has no control over the visible number of rows: you can make changes in UIScrollViewer to do that. |
getScrollbarVisibility() (UIScrollViewer object).getScrollPage() |
See usage above and documentation. |
minimumSize(int, int) (no suggestions) |
Deprecated in AWT 1.1 |
paramString() getName(), etc. |
Use the getXXX methods to find the exact information you need. |
preferredSize(int, int) (no suggestions) |
Deprecated in AWT 1.1 |
replaceRange(String,
int, int) (no suggestions) |
|
replaceText(String,
int, int) (no suggestions) |
|
setColumns(int) (see UIScrollViewer) |
UIEdit has no control over the visible number of columns: you can make changes in UIScrollViewer to do that. |
setRows(int) (see UIScrollViewer) |
UIEdit has no control over the visible number of rows: you can make changes in UIScrollViewer to do that. |
SCROLLBARS_BOTH SCROLLBARS_HORIZONTAL_ONLY SCROLLBARS_NONE SCROLLBARS_VERTICAL_ONLY (see UIScrollViewer) |
These kinds of settings need to be set using the styles in UIScrollViewer. |