KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > helloworld > listeners > HelloWorldAdd_li


1 /*******************************************************************************
2  * Copyright (c) 2004, Dirk von der Weiden.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * Dirk von der Weiden - initial API and implementation
10  *
11  * Created on 13.02.2005
12  *
13  * date: 13.02.2005
14  * project: WiSer-HelloWorld
15  *
16  * *******************************************************************************/

17
18 package helloworld.listeners;
19
20 import Jmc.baseGui.*;
21 import Jmc.commonGui.*;
22 import Jmc.baseTools.*;
23
24 /**
25  * @author Dirk
26  *
27  * date: 13.02.2005
28  *
29  * <p>
30  * Purpose: The listener adds a node to the tree. The name of the node is specified in the edit field
31  * </p>
32  */

33 public class HelloWorldAdd_li implements base_guiListener
34 {
35
36   /**
37      * <p>
38      * Is called by the framework whenever an event has been fired by the corresponding widget
39      * </p><p>
40      *
41      * </p><p>
42      * @param Widget which generated the event
43      * </p>
44      */

45     public void pcmf_execListener(base_guiObj xParam) throws Exception JavaDoc
46     {
47     // get all relevant widgets from the registry
48
base_inputField_if l_inp = (base_inputField_if)base_registredObject.pcmf_getObjByName("myNodeInput");
49     base_treeView_if l_tree = (base_treeView_if) base_registredObject.pcmf_getObjByName("atree");
50     base_image_if l_icon = (base_image_if) base_registredObject.pcmf_getObjByName("entry_icon");
51     
52     // get selected node in the tree
53
base_treeNode l_selected = (base_treeNode)l_tree.pcmf_getValue();
54     
55     // sorry no selection: return
56
if (l_selected == null)
57       return;
58
59     // create new node
60
simpleNode l_new = new simpleNode(l_inp.pcmf_getValue().toString());
61     // set icon
62
l_new.pcmf_setIcon(l_icon);
63     
64     // add node to current selected node
65
l_selected.pcmf_addNode(l_inp.pcmf_getValue().toString(), l_new);
66     
67     // be shure that the tree repaints
68
l_tree.pcmf_repaint();
69     
70     return;
71     }
72
73 }
74
Popular Tags