}
};
public void startup(Display display, Dictionary<String, String> properties)
throws Exception {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
frame = new Frame((Component)wtkxSerializer.readObject(getClass().getResource("text_area_test.wtkx")));
frame.setTitle("TextArea Test");
frame.setPreferredSize(640, 480);
frame.open(display);
textArea = (TextArea)wtkxSerializer.getObjectByID("textArea");
textArea.getTextAreaSelectionListeners().add(new TextAreaSelectionListener() {
public void selectionChanged(TextArea textArea,
int previousSelectionStart, int previousSelectionLength) {
selectionStartLabel.setText(Integer.toString(textArea.getSelectionStart()));
selectionLengthLabel.setText(Integer.toString(textArea.getSelectionLength()));
}
});
selectionStartLabel = (Label)wtkxSerializer.getObjectByID("selectionStartLabel");
selectionLengthLabel = (Label)wtkxSerializer.getObjectByID("selectionLengthLabel");
treeView = (TreeView)wtkxSerializer.getObjectByID("treeView");
treeView.getTreeViewSelectionListeners().add(new TreeViewSelectionListener() {
public void selectedPathAdded(TreeView treeView, Path path) {
// No-op
}
public void selectedPathRemoved(TreeView treeView, Path path) {
// No-op
}
public void selectedPathsChanged(TreeView treeView,
Sequence<Path> previousSelectedPaths) {
Path selectedPath = treeView.getSelectedPath();
if (selectedNode != null) {
selectedNode.getNodeListeners().remove(selectedNodeListener);
}
if (selectedPath == null) {
selectedNode = null;
} else {
NodeAdapter nodeAdapter = Sequence.Tree.get(documentAdapter, selectedPath);
selectedNode = nodeAdapter.getNode();
}
if (selectedNode != null) {
selectedNode.getNodeListeners().add(selectedNodeListener);
}
updateSelectedNodeData();
}
});
offsetLabel = (Label)wtkxSerializer.getObjectByID("offsetLabel");
charactersLabel = (Label)wtkxSerializer.getObjectByID("charactersLabel");
documentAdapter = new DocumentAdapter(textArea.getDocument());
treeView.setTreeData(documentAdapter);
}