use of org.jpos.ui.UI in project jPOS by jpos.
the class JTreeFactory method create.
public JComponent create(UI ui, Element e) {
final UI parentUI = ui;
final Map map = new HashMap();
final JTree tree = new JTree(getNode(e, map));
String font = e.getAttributeValue("font");
if (font != null)
tree.setFont(Font.decode(font));
tree.setRootVisible(e.getTextTrim().length() > 0);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent evt) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node != null) {
String s = (String) map.get(node);
if (s != null) {
StringTokenizer st = new StringTokenizer(s);
String action = st.nextToken();
String command = null;
if (st.hasMoreTokens())
command = st.nextToken();
ActionListener al = (ActionListener) parentUI.get(action);
if (al != null) {
al.actionPerformed(new ActionEvent(node, 0, command));
}
// System.out.println ("ACTION: " + action);
// System.out.println ("COMMAND: " + command);
}
}
}
});
return tree;
}
Aggregations