Java Doc for Bindings.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.Bindings

Bindings
final public class Bindings (Code)
Consists only of static methods that bind Swing components to ValueModels. This is one of two helper classes that assist you in establishing a binding: 1) this Bindings class binds components that have been created before; it wraps ValueModels with the adapters from package com.jgoodies.binding.adapter. 2) the BasicComponentFactory creates Swing components that are then bound using this Bindings class.

If you have an existing factory that vends Swing components, you can use this Bindings class to bind them to ValueModels. If you don't have such a factory, you can use the BasicComponentFactory or a custom subclass to create and bind Swing components.

The binding process for JCheckBox, JRadioButton, and other AbstractButtons retains the former enablement state. Before the new (adapting) model is set, the enablement is requested from the model, not the button. This enablement is set after the new model has been set.

TODO: Consider adding binding methods for JProgressBar, JSlider, JSpinner, and JTabbedPane.

TODO: Consider adding connection methods for pairs of bean properties. In addition to the PropertyConnector's connect method, this could add boolean operators such as: not, and, or, nor.
author:
   Karsten Lentzsch
version:
   $Revision: 1.32 $
See Also:   com.jgoodies.binding.value.ValueModel
See Also:   BasicComponentFactory



Field Summary
final static  FocusLostHandlerFOCUS_LOST_HANDLER
     Triggers a commit in the shared focus lost trigger if focus is lost permanently.
final static  WeakTriggerFOCUS_LOST_TRIGGER
     Holds a weak trigger that is shared by BufferedValueModels that commit on permanent focus change.


Method Summary
public static  voidaddComponentPropertyHandler(JComponent component, ValueModel valueModel)
     If the given model is a ComponentValueModel, a component property handler is registered with this model.
public static  voidbind(JCheckBox checkBox, ValueModel valueModel)
     Binds a JCheckBox to the given ValueModel and retains the enablement state.
public static  voidbind(JCheckBoxMenuItem checkBoxMenuItem, ValueModel valueModel)
     Binds a JCheckBoxMenuItem to the given ValueModel and retains the enablement state.
public static  voidbind(JColorChooser colorChooser, ValueModel valueModel)
     Binds a JColorChooser to the given Color-typed ValueModel. The ValueModel must be of type Color and must allow read-access to its value.

Also, it is strongly recommended (though not required) that the underlying ValueModel provides only non-null values. This is so because the ColorSelectionModel behavior is undefined for null values and it may have unpredictable results. To avoid these problems, you may bind the ColorChooser with a default color using Bindings.bind(JColorChooser,ValueModel,Color) .

Since the color chooser is considered a container, not a single component, it is not synchronized with the valueModel's ComponentValueModel properties - if any.

Note: There's a bug in Java 1.4.2, Java 5 and Java 6 that affects this binding.

public static  voidbind(JColorChooser colorChooser, ValueModel valueModel, Color defaultColor)
     Binds a JColorChooser to the given Color-typed ValueModel. The ValueModel must be of type Color and must allow read-access to its value.
public static  voidbind(JComboBox comboBox, SelectionInList<E> selectionInList)
     Binds a non-editable JComboBox to the given SelectionInList using the SelectionInList's ListModel as list data provider and the SelectionInList's selection index holder for the combo box model's selected item.

There are a couple of other possibilities to bind a JComboBox.

public static  voidbind(JFormattedTextField textField, ValueModel valueModel)
     Binds the given JFormattedTextField to the specified ValueModel.
public static  voidbind(JLabel label, ValueModel valueModel)
     Binds the given JLabel to the specified ValueModel.
public static  voidbind(JList list, SelectionInList<E> selectionInList)
     Binds a JList to the given SelectionInList using the SelectionInList's ListModel as list data provider and the SelectionInList's selection index holder for the selection model.

Since version 2.0 the list's enabled and visible state is synchronized with the selectionInList's selection holder, if it's a ComponentValueModel .

public static  voidbind(JRadioButton radioButton, ValueModel model, Object choice)
     Binds a JRadioButton to the given ValueModel and retains the enablement state.
public static  voidbind(JRadioButtonMenuItem radioButtonMenuItem, ValueModel model, Object choice)
     Binds a JRadioButtonMenuItem to the given ValueModel and retains the enablement state.
public static  voidbind(JTextArea textArea, ValueModel valueModel)
     Binds a text area to the given ValueModel.
public static  voidbind(JTextArea textArea, ValueModel valueModel, boolean commitOnFocusLost)
     Binds a text area to the given ValueModel.
public static  voidbind(JTextField textField, ValueModel valueModel)
     Bind a text fields or password field to the given ValueModel. The model is updated on every character typed.

Security Note: If you use this method to bind a JPasswordField, the field's password will be requested as Strings from the field and will be held as String by the given ValueModel. These password String could potentially be observed in a security fraud. For stronger security it is recommended to request a character array from the JPasswordField and clear the array after use by setting each character to zero.

public static  voidbind(JTextField textField, ValueModel valueModel, boolean commitOnFocusLost)
     Binds a text field or password field to the given ValueModel. The model can be updated on focus lost or on every character typed.

Security Note: If you use this method to bind a JPasswordField, the field's password will be requested as Strings from the field and will be held as String by the given ValueModel. These password String could potentially be observed in a security fraud. For stronger security it is recommended to request a character array from the JPasswordField and clear the array after use by setting each character to zero.

public static  voidbind(JComponent component, String propertyName, ValueModel valueModel)
     Binds the specified property of the given JComponent to the specified ValueModel.
public static  voidcommitImmediately()
     Commits a pending edit - if any.
public static  booleanflushImmediately()
     Flushes a pending edit in the focused text component - if any. Useful to revert edited values in bound text components that commit on focus-lost.
public static  booleanisFocusOwnerBuffering()
     Checks and answers whether the focus owner is a component that buffers a pending edit.
public static  voidremoveComponentPropertyHandler(JComponent component)
     If the given component holds a ComponentValueModel and a ComponentPropertyHandler in its client properties, the handler is removed as listener from the model, and the model and handler are removed from the client properties.

Field Detail
FOCUS_LOST_HANDLER
final static FocusLostHandler FOCUS_LOST_HANDLER(Code)
Triggers a commit in the shared focus lost trigger if focus is lost permanently. Shared among all components that are configured to commit on focus lost.
See Also:   Bindings.createCommitOnFocusLostModel(ValueModel,Component)



FOCUS_LOST_TRIGGER
final static WeakTrigger FOCUS_LOST_TRIGGER(Code)
Holds a weak trigger that is shared by BufferedValueModels that commit on permanent focus change.
See Also:   Bindings.createCommitOnFocusLostModel(ValueModel,Component)





Method Detail
addComponentPropertyHandler
public static void addComponentPropertyHandler(JComponent component, ValueModel valueModel)(Code)
If the given model is a ComponentValueModel, a component property handler is registered with this model. This handler updates the component state if the ComponentValueModel indicates a change in one of its properties, for example: visible, enabled, and editable.

Also the ComponentValueModel and the component handler are stored as client properties with the component. This way they can be removed later using #removeComponentPropertyHandler.
Parameters:
  component - the component where the handler is registered
Parameters:
  valueModel - the model to observe
See Also:   Bindings.removeComponentPropertyHandler(JComponent)
See Also:   ComponentValueModel
since:
   1.1




bind
public static void bind(JCheckBox checkBox, ValueModel valueModel)(Code)
Binds a JCheckBox to the given ValueModel and retains the enablement state. The bound check box is selected if and only if the model's value equals Boolean.TRUE.

The value model is converted to the required interface ToggleButtonModel using a ToggleButtonAdapter.
Parameters:
  checkBox - the check box to be bound
Parameters:
  valueModel - the model that provides a Boolean value
throws:
  NullPointerException - if the checkBox or valueModelis null




bind
public static void bind(JCheckBoxMenuItem checkBoxMenuItem, ValueModel valueModel)(Code)
Binds a JCheckBoxMenuItem to the given ValueModel and retains the enablement state. The bound menu item is selected if and only if the model's value equals Boolean.TRUE.

Note: For users of the JGoodies UIF (user interface framework) the recommended way to create and bind check box menu items is the class com.jgoodies.uif.ToggleAction.

The value model is converted to the required interface ToggleButtonModel using a ToggleButtonAdapter.
Parameters:
  checkBoxMenuItem - the check box menu item to be bound
Parameters:
  valueModel - the model that provides a Boolean value
throws:
  NullPointerException - if the menu item or valueModelis null




bind
public static void bind(JColorChooser colorChooser, ValueModel valueModel)(Code)
Binds a JColorChooser to the given Color-typed ValueModel. The ValueModel must be of type Color and must allow read-access to its value.

Also, it is strongly recommended (though not required) that the underlying ValueModel provides only non-null values. This is so because the ColorSelectionModel behavior is undefined for null values and it may have unpredictable results. To avoid these problems, you may bind the ColorChooser with a default color using Bindings.bind(JColorChooser,ValueModel,Color) .

Since the color chooser is considered a container, not a single component, it is not synchronized with the valueModel's ComponentValueModel properties - if any.

Note: There's a bug in Java 1.4.2, Java 5 and Java 6 that affects this binding. The BasicColorChooserUI doesn't listen to changes in the selection model, and so the preview panel won't update if the selected color changes. As a workaround you can use BasicComponentFactory.createColorChooser(ValueModel) , or you could use a Look&Feel that fixes the bug mentioned above.
Parameters:
  colorChooser - the color chooser to be bound
Parameters:
  valueModel - the model that provides non-nullColor values.
throws:
  NullPointerException - if the color chooser or value modelis null
See Also:   Bindings.bind(JColorChooser,ValueModel,Color)
since:
   1.0.3




bind
public static void bind(JColorChooser colorChooser, ValueModel valueModel, Color defaultColor)(Code)
Binds a JColorChooser to the given Color-typed ValueModel. The ValueModel must be of type Color and must allow read-access to its value. The default color will be used if the valueModel returns null.

Since the color chooser is considered a container, not a single component, it is not synchronized with the valueModel's ComponentValueModel properties - if any.

Note: There's a bug in Java 1.4.2, Java 5 and Java 6 that affects this binding. The BasicColorChooserUI doesn't listen to changes in the selection model, and so the preview panel won't update if the selected color changes. As a workaround you can use BasicComponentFactory.createColorChooser(ValueModel) , or you could use a Look&Feel that fixes the bug mentioned above.
Parameters:
  colorChooser - the color chooser to be bound
Parameters:
  valueModel - the model that provides non-nullColor values.
Parameters:
  defaultColor - the color used if the valueModel returns null
throws:
  NullPointerException - if the color chooser, value model,or default color is null
since:
   1.1




bind
public static void bind(JComboBox comboBox, SelectionInList<E> selectionInList)(Code)
Binds a non-editable JComboBox to the given SelectionInList using the SelectionInList's ListModel as list data provider and the SelectionInList's selection index holder for the combo box model's selected item.

There are a couple of other possibilities to bind a JComboBox. See the constructors and the class comment of the ComboBoxAdapter .

Since version 2.0 the combo's enabled and visible state is synchronized with the selectionInList's selection holder, if it's a ComponentValueModel .
Parameters:
  comboBox - the combo box to be bound
Parameters:
  selectionInList - provides the list and selection;if the selection holder is a ComponentValueModel, it is synchronizedwith the comboBox properties visible and enabled<
Parameters:
  E - > the type of the combo box items
throws:
  NullPointerException - if the combo box or the selectionInListis null
See Also:   ComboBoxAdapter
since:
   1.0.1




bind
public static void bind(JFormattedTextField textField, ValueModel valueModel)(Code)
Binds the given JFormattedTextField to the specified ValueModel. Synchronized the ValueModel's value with the text field's value by means of a PropertyConnector.
Parameters:
  textField - the JFormattedTextField that is to be bound
Parameters:
  valueModel - the model that provides the value
throws:
  NullPointerException - if the text field or valueModelis null



bind
public static void bind(JLabel label, ValueModel valueModel)(Code)
Binds the given JLabel to the specified ValueModel.
Parameters:
  label - a label that shall be bound to the given value model
Parameters:
  valueModel - the model that provides the value
throws:
  NullPointerException - if the label or valueModel is null



bind
public static void bind(JList list, SelectionInList<E> selectionInList)(Code)
Binds a JList to the given SelectionInList using the SelectionInList's ListModel as list data provider and the SelectionInList's selection index holder for the selection model.

Since version 2.0 the list's enabled and visible state is synchronized with the selectionInList's selection holder, if it's a ComponentValueModel .
Parameters:
  list - the list to be bound
Parameters:
  selectionInList - provides the list and selection;if the selection holder is a ComponentValueModel, it is synchronizedwith the list properties visible and enabled<
Parameters:
  E - > the type of the list items
throws:
  NullPointerException - if the list or the selectionInListis null




bind
public static void bind(JRadioButton radioButton, ValueModel model, Object choice)(Code)
Binds a JRadioButton to the given ValueModel and retains the enablement state. The bound radio button is selected if and only if the model's value equals the specified choice value.

The model is converted to the required interface ToggleButtonModel using a RadioButtonAdapter.
Parameters:
  radioButton - the radio button to be bound to the given model
Parameters:
  model - the model that provides the current choice
Parameters:
  choice - this button's value
throws:
  NullPointerException - if the valueModel is null




bind
public static void bind(JRadioButtonMenuItem radioButtonMenuItem, ValueModel model, Object choice)(Code)
Binds a JRadioButtonMenuItem to the given ValueModel and retains the enablement state. The bound menu item is selected if and only if the model's value equals the specified choice.

Note: For users of the JGoodies UIF (user interface framework) the recommended way to create and bind radio button menu items is the class com.jgoodies.uif.ToggleAction.

The model is converted to the required interface ToggleButtonModel using a RadioButtonAdapter.
Parameters:
  radioButtonMenuItem - the radio item to be bound to the given model
Parameters:
  model - the model that provides the current choice
Parameters:
  choice - this button's value
throws:
  NullPointerException - if the valueModel is null




bind
public static void bind(JTextArea textArea, ValueModel valueModel)(Code)
Binds a text area to the given ValueModel. The model is updated on every character typed.

TODO: Consider changing the semantics to commit on focus lost. This would be consistent with the text component vending factory methods in the BasicComponentFactory that have no boolean parameter.
Parameters:
  textArea - the text area to be bound to the value model
Parameters:
  valueModel - the model that provides the text value
throws:
  NullPointerException - if the text component or valueModelis null




bind
public static void bind(JTextArea textArea, ValueModel valueModel, boolean commitOnFocusLost)(Code)
Binds a text area to the given ValueModel. The model can be updated on focus lost or on every character typed. The DocumentAdapter used in this binding doesn't filter newlines.
Parameters:
  textArea - the text area to be bound to the value model
Parameters:
  valueModel - the model that provides the text value
Parameters:
  commitOnFocusLost - true to commit text changes on focus lost,false to commit text changes on every character typed
throws:
  NullPointerException - if the text component or valueModelis null



bind
public static void bind(JTextField textField, ValueModel valueModel)(Code)
Bind a text fields or password field to the given ValueModel. The model is updated on every character typed.

Security Note: If you use this method to bind a JPasswordField, the field's password will be requested as Strings from the field and will be held as String by the given ValueModel. These password String could potentially be observed in a security fraud. For stronger security it is recommended to request a character array from the JPasswordField and clear the array after use by setting each character to zero. Method JPasswordField.getPassword return's the field's password as a character array.

TODO: Consider changing the semantics to commit on focus lost. This would be consistent with the text component vending factory methods in the BasicComponentFactory that have no boolean parameter.
Parameters:
  textField - the text field to be bound to the value model
Parameters:
  valueModel - the model that provides the text value
throws:
  NullPointerException - if the text component or valueModelis null
See Also:   JPasswordField.getPassword




bind
public static void bind(JTextField textField, ValueModel valueModel, boolean commitOnFocusLost)(Code)
Binds a text field or password field to the given ValueModel. The model can be updated on focus lost or on every character typed.

Security Note: If you use this method to bind a JPasswordField, the field's password will be requested as Strings from the field and will be held as String by the given ValueModel. These password String could potentially be observed in a security fraud. For stronger security it is recommended to request a character array from the JPasswordField and clear the array after use by setting each character to zero. Method JPasswordField.getPassword return's the field's password as a character array.
Parameters:
  textField - the text field to be bound to the value model
Parameters:
  valueModel - the model that provides the text value
Parameters:
  commitOnFocusLost - true to commit text changes on focus lost,false to commit text changes on every character typed
throws:
  NullPointerException - if the text component or valueModelis null
See Also:   JPasswordField.getPassword




bind
public static void bind(JComponent component, String propertyName, ValueModel valueModel)(Code)
Binds the specified property of the given JComponent to the specified ValueModel. Synchronizes the ValueModel's value with the component's property by means of a PropertyConnector.
Parameters:
  component - the JComponent that is to be bound
Parameters:
  propertyName - the name of the property to be bound
Parameters:
  valueModel - the model that provides the value
throws:
  NullPointerException - if the component or value modelor property name is null
since:
   1.2



commitImmediately
public static void commitImmediately()(Code)
Commits a pending edit - if any. Useful to ensure that edited values in bound text components that commit on focus-lost are committed before an operation is performed that uses the value to be committed after a focus lost.

For example, before you save a form, a value that has been edited shall be committed, so the validation can check whether the save is allowed or not.
since:
   1.2




flushImmediately
public static boolean flushImmediately()(Code)
Flushes a pending edit in the focused text component - if any. Useful to revert edited values in bound text components that commit on focus-lost. This operation can be performed on an escape key event like the Cancel action in the JFormattedTextField.

Returns whether an edit has been reset. Useful to decide whether a key event shall be consumed or not. true if a pending edit has been reset, false if the focused component isn't buffering ordoesn't buffer at all
See Also:   Bindings.isFocusOwnerBuffering()
since:
   2.0.1




isFocusOwnerBuffering
public static boolean isFocusOwnerBuffering()(Code)
Checks and answers whether the focus owner is a component that buffers a pending edit. Useful to enable or disable a text component Action that resets the edited value.

See also the JFormattedTextField's internal CancelAction . true if the focus owner is a JTextComponentthat commits on focus-lost and is buffering
See Also:   Bindings.flushImmediately()
since:
   2.0.1




removeComponentPropertyHandler
public static void removeComponentPropertyHandler(JComponent component)(Code)
If the given component holds a ComponentValueModel and a ComponentPropertyHandler in its client properties, the handler is removed as listener from the model, and the model and handler are removed from the client properties.
Parameters:
  component -
See Also:   Bindings.addComponentPropertyHandler(JComponent,ValueModel)
See Also:   ComponentValueModel
since:
   1.1



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.