View Javadoc

1   /*
2    * @(#)$Id: TextFieldBinding.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.JTextField;
29  
30  import org.ximtec.igesture.core.DataObject;
31  
32  
33  public class TextFieldBinding extends DataBinding<JTextField> {
34  
35     private JTextField textField;
36  
37  
38     public TextFieldBinding(JTextField textField, DataObject obj, String property) {
39        super(obj, property);
40        this.textField = textField;
41        this.textField.addFocusListener(this);
42        updateView();
43     }
44  
45  
46     @Override
47     public JTextField getComponent() {
48        return textField;
49     }
50  
51  
52     @Override
53     protected void updateView() {
54        textField.setText(getValue());
55     }
56  
57  
58     @Override
59     protected void updateModel() {
60        setValue(textField.getText());
61     }
62  }