JGoodies Binding: Property Connector Example : Data Binding « Swing Components « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » Swing Components » Data Binding 




JGoodies Binding: Property Connector Example
JGoodies Binding: Property Connector Example

/*
Code revised from Desktop Java Live:
http://www.sourcebeat.com/downloads/
*/

import java.text.ParseException;

import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.text.MaskFormatter;

import com.jgoodies.binding.beans.PropertyConnector;
import com.jgoodies.binding.value.ValueHolder;
import com.jgoodies.binding.value.ValueModel;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.FormLayout;

public class PropertyConnectorExample extends JPanel {
    public PropertyConnectorExample() {
        DefaultFormBuilder defaultFormBuilder = new DefaultFormBuilder(new FormLayout("p, 2dlu, p"));
        defaultFormBuilder.setDefaultDialogBorder();

        ValueModel socialSecurityNumberModel = new ValueHolder();
        socialSecurityNumberModel.setValue("123-45-6789");

        MaskFormatter maskFormatter = null;
        try {
            maskFormatter = new MaskFormatter("###-##-####");
        catch (ParseException e) {
            //Shouldn't Happen
        }

        JFormattedTextField socialSecurityTextField = new JFormattedTextField(maskFormatter);

        PropertyConnector propertyConnector1 = new PropertyConnector(socialSecurityNumberModel, "value", socialSecurityTextField, "value");
        propertyConnector1.updateProperty2();
        defaultFormBuilder.append("Formatted Text Field:", socialSecurityTextField);


        JLabel socialSecurityLabel = new JLabel();
        PropertyConnector propertyConnector2 = new PropertyConnector(socialSecurityNumberModel, "value", socialSecurityLabel, "text");
        propertyConnector2.updateProperty2();
        defaultFormBuilder.append("Label:", socialSecurityLabel);
        defaultFormBuilder.append(new JButton("Focus Button")3);

        add(defaultFormBuilder.getPanel());
    }

    public static void main(String[] a){
      JFrame f = new JFrame("Property Connector Example");
      f.setDefaultCloseOperation(2);
      f.add(new PropertyConnectorExample());
      f.pack();
      f.setVisible(true);
    }
}


           
       














jgoodiesDataBinding.zip( 254 k)
Related examples in the same category
1.Demonstrates three different styles when to commit changesDemonstrates three different styles when to commit changes
2.Builds an editor with components bound to the domain object propertiesBuilds an editor with components bound to the domain object properties
3.Using buffered adapting ValueModels created by a PresentationModelUsing buffered adapting ValueModels created by a PresentationModel
4.Builds an editor that copies data from the domain back and forthBuilds an editor that copies data from the domain back and forth
5.JGoodies Binding: Selection In List Bean Channel ExampleJGoodies Binding: Selection In List Bean Channel Example
6.JGoodies Binding: Selection In List ExampleJGoodies Binding: Selection In List Example
7.JGoodies Binding: Selection In List Model ExampleJGoodies Binding: Selection In List Model Example
8.JGoodies Binding: Toggle Button Adapter ExampleJGoodies Binding: Toggle Button Adapter Example
9.JGoodies Binding: Value Holder ExampleJGoodies Binding: Value Holder Example
10.JGoodies Binding: Abstract Table Model ExampleJGoodies Binding: Abstract Table Model Example
11.JGoodies Binding: Basic Component Factory ExampleJGoodies Binding: Basic Component Factory Example
12.JGoodies Binding: Bean Adapter ExampleJGoodies Binding: Bean Adapter Example
13.JGoodies Binding: Bounded Range Adapter ExampleJGoodies Binding: Bounded Range Adapter Example
14.JGoodies Binding: Buffering Presentation Model ExampleJGoodies Binding: Buffering Presentation Model Example
15.JGoodies Binding: ComboBox Adapter ExampleJGoodies Binding: ComboBox Adapter Example
16.JGoodies Binding: Converter Factory ExampleJGoodies Binding: Converter Factory Example
17.JGoodies Binding: Feed Bean Example 1JGoodies Binding: Feed Bean Example 1
18.JGoodies Binding: Feed Bean Example 2JGoodies Binding: Feed Bean Example 2
19.JGoodies Binding: Feed Bean Example 3JGoodies Binding: Feed Bean Example 3
20.JGoodies Binding: Presentation Bean Channel ExampleJGoodies Binding: Presentation Bean Channel Example
21.JGoodies Binding: Presentation Bean Property Change Listener ExampleJGoodies Binding: Presentation Bean Property Change Listener Example
22.JGoodies Binding: Presentation Model Property Change ExampleJGoodies Binding: Presentation Model Property Change Example
23.JGoodies Binding: Property Adapter Example 1JGoodies Binding: Property Adapter Example 1
24.JGoodies Binding: Property Adapter Example 2JGoodies Binding: Property Adapter Example 2
25.JGoodies Binding: Property Adapter Example 3JGoodies Binding: Property Adapter Example 3
26.JGoodies Binding: Radio Button Adapter ExampleJGoodies Binding: Radio Button Adapter Example
27.Swingx: Swing Data BindingSwingx: Swing Data Binding
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.