View Javadoc

1   /*
2    * @(#)$Id: LabelBinding.java 742 2009-08-15 17:15:49Z kurmannu $
3    *
4    * Author   : Ueli Kurmann, igesture@uelikurmann.ch
5    *                                   
6    *                                   
7    * Purpose  : 
8    *
9    * -----------------------------------------------------------------------
10   *
11   * Revision Information:
12   *
13   * Date       Who     Reason
14   *
15   * 23.03.2008 ukurmann  Initial Release
16   *
17   * -----------------------------------------------------------------------
18   *
19   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
20   *
21   * This software is the proprietary information of ETH Zurich.
22   * Use is subject to license terms.
23   * 
24   */
25  
26  package org.ximtec.igesture.tool.binding;
27  
28  import javax.swing.JLabel;
29  
30  import org.sigtec.util.Constant;
31  import org.ximtec.igesture.core.DataObject;
32  
33  
34  public class LabelBinding extends DataBinding<JLabel> {
35  
36     private JLabel label;
37     
38     private String prefix;
39  
40  
41     public LabelBinding(JLabel textField, DataObject obj, String property, String prefix) {
42        super(obj, property);
43        this.label = textField;
44        this.prefix = prefix;
45        updateView();
46     }
47     
48     public LabelBinding(JLabel textField, DataObject obj, String property) {
49        this(textField, obj, property, Constant.EMPTY_STRING);
50     }
51  
52  
53     @Override
54     public JLabel getComponent() {
55        return label;
56     }
57  
58  
59     @Override
60     protected void updateView() {
61        label.setText(prefix + getValue());
62     }
63  
64  
65     @Override
66     protected void updateModel() {
67        // do nothing, read only component
68     }
69  }