KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > counter > listeners > Counter_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 14.06.2004
12  *
13  * date: 14.06.2004
14  * project: WiSer-Calculator
15  *
16  * *******************************************************************************/

17
18 package counter.listeners;
19
20 import Jmc.baseGui.*;
21 import Jmc.baseTools.*;
22 import Jmc.commonGui.*;
23
24 /**
25  * @author Dirk
26  *
27  * date: 14.06.2004
28  *
29  * <p>
30  * Purpose: This listener handles all events from the counter
31  * </p>
32  */

33 public class Counter_li implements base_guiListener
34 {
35   private int pem_cnt = 0;
36   /**
37      * <p>
38      * This method is called whenever the button is pressed.
39      * </p><p>
40      *
41      * </p><p>
42      * @param xParam the widget which generates the event
43      * </p>
44      */

45   public void pcmf_execListener(base_guiObj xParam) throws Exception JavaDoc
46   {
47     // get the widget from the registry
48
base_guiWidget_if l_disp = (base_guiWidget_if)base_registredObject.pcmf_getObjByName("display");
49
50     // get the value of the pressed button
51
String JavaDoc l_value = (String JavaDoc)xParam.pcmf_getValue();
52     
53     if (l_value.equals("inc (+)"))
54       this.pem_cnt ++;
55     else
56     if (l_value.equals("dec (-)"))
57       this.pem_cnt --;
58     else
59     if (l_value.equals("reset"))
60       this.pem_cnt = 0;
61    
62    // set the new string
63
l_disp.pcmf_setValue(Integer.toString(this.pem_cnt));
64    
65    // repaint the counters display
66
l_disp.pcmf_repaint();
67     
68     return;
69   }
70 }
Popular Tags