Java Doc for TextComponentConnector.java in  » Swing-Library » jgoodies-data-binding » com » jgoodies » binding » adapter » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jgoodies data binding » com.jgoodies.binding.adapter 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.jgoodies.binding.adapter.TextComponentConnector

TextComponentConnector
final public class TextComponentConnector (Code)
Connects a String typed ValueModel and a JTextField or JTextArea. At construction time the text component content is updated with the subject's contents.

This connector has been designed for text components that display a plain String. In case of a JEditorPane, the binding may require more information then the plain String, for example styles. Since this is outside the scope of this connector, the public constructors prevent a construction for general JTextComponents. If you want to establish a one-way binding for a display JEditorPane, use a custom listener instead.

This class provides limited support for handling subject value modifications while updating the subject. If a Document change initiates a subject value update, the subject will be observed and a property change fired by the subject will be handled - if any. In most cases, the subject will notify about a change to the text that was just set by this connector. However, in some cases the subject may decide to modify this text, for example to ensure upper case characters. Since at this moment, this adapter's Document is still write-locked, the Document update is performed later using SwingUtilities#invokeLater.

Note: Such an update will typically change the Caret position in JTextField's and other JTextComponent's that are synchronized using this class. Hence, the subject value modifications can be used with commit-on-focus-lost text components, but typically not with a commit-on-key-typed component. For the latter case, you may consider using a custom DocumentFilter.

Constraints: The ValueModel must be of type String.

Examples:

 ValueModel lastNameModel = new PropertyAdapter(customer, "lastName", true);
 JTextField lastNameField = new JTextField();
 TextComponentConnector.connect(lastNameModel, lastNameField);
 ValueModel codeModel = new PropertyAdapter(shipment, "code", true);
 JTextField codeField = new JTextField();
 TextComponentConnector connector =
 new TextComponentConnector(codeModel, codeField);
 connector.updateTextComponent();
 

author:
   Karsten Lentzsch
version:
   $Revision: 1.9 $
See Also:   ValueModel
See Also:   Document
See Also:   PlainDocument
since:
   1.2



Constructor Summary
public  TextComponentConnector(ValueModel subject, JTextArea textArea)
     Constructs a TextComponentConnector that connects the specified String-typed subject ValueModel with the given text area.

In case you don't need the TextComponentConnector instance, you better use one of the static #connect methods.

public  TextComponentConnector(ValueModel subject, JTextField textField)
     Constructs a TextComponentConnector that connects the specified String-typed subject ValueModel with the given text field.

In case you don't need the TextComponentConnector instance, you better use one of the static #connect methods.


Method Summary
public static  voidconnect(ValueModel subject, JTextArea textArea)
     Establishes a synchronization between the specified String-typed subject ValueModel and the given text area.
public static  voidconnect(ValueModel subject, JTextField textField)
     Establishes a synchronization between the specified String-typed subject ValueModel and the given text field.
public  voidrelease()
     Removes the internal listeners from the subject, text component, and text component's document.
public  voidupdateSubject()
     Reads the current text from the document and sets it as new value of the subject.
public  voidupdateTextComponent()
    


Constructor Detail
TextComponentConnector
public TextComponentConnector(ValueModel subject, JTextArea textArea)(Code)
Constructs a TextComponentConnector that connects the specified String-typed subject ValueModel with the given text area.

In case you don't need the TextComponentConnector instance, you better use one of the static #connect methods. This constructor may confuse developers, if you just use the side effects performed in the constructor; this is because it is quite unconventional to instantiate an object that you never use.
Parameters:
  subject - the underlying String typed ValueModel
Parameters:
  textArea - the JTextArea to be synchronized with the ValueModel
throws:
  NullPointerException - if the subject or text area is null




TextComponentConnector
public TextComponentConnector(ValueModel subject, JTextField textField)(Code)
Constructs a TextComponentConnector that connects the specified String-typed subject ValueModel with the given text field.

In case you don't need the TextComponentConnector instance, you better use one of the static #connect methods. This constructor may confuse developers, if you just use the side effects performed in the constructor; this is because it is quite unconventional to instantiate an object that you never use.
Parameters:
  subject - the underlying String typed ValueModel
Parameters:
  textField - the JTextField to be synchronized with the ValueModel
throws:
  NullPointerException - if the subject or text field is null





Method Detail
connect
public static void connect(ValueModel subject, JTextArea textArea)(Code)
Establishes a synchronization between the specified String-typed subject ValueModel and the given text area. Does not synchronize now.
Parameters:
  subject - the underlying String typed ValueModel
Parameters:
  textArea - the JTextArea to be synchronized with the ValueModel
throws:
  NullPointerException - if the subject or text area is null



connect
public static void connect(ValueModel subject, JTextField textField)(Code)
Establishes a synchronization between the specified String-typed subject ValueModel and the given text field. Does not synchronize now.
Parameters:
  subject - the underlying String typed ValueModel
Parameters:
  textField - the JTextField to be synchronized with the ValueModel
throws:
  NullPointerException - if the subject or text area is null



release
public void release()(Code)
Removes the internal listeners from the subject, text component, and text component's document. This connector must not be used after calling #release.

To avoid memory leaks it is recommended to invoke this method, if the ValueModel lives much longer than the text component. Instead of releasing a text connector, you typically make the ValueModel obsolete by releasing the PresentationModel or BeanAdapter that has created the ValueModel.

As an alternative you may use ValueModels that in turn use event listener lists implemented using WeakReference.
See Also:   PresentationModel.release
See Also:   BeanAdapter.release
See Also:   java.lang.ref.WeakReference




updateSubject
public void updateSubject()(Code)
Reads the current text from the document and sets it as new value of the subject.



updateTextComponent
public void updateTextComponent()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.