JGoodies Binding: Value Holder Example : Data Binding « Swing Components « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Swing Components » Data BindingScreenshots 
JGoodies Binding: Value Holder Example
JGoodies Binding: Value Holder Example

/*
Code revised from Desktop Java Live:
http://www.sourcebeat.com/downloads/
*/
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.jgoodies.binding.adapter.BasicComponentFactory;
import com.jgoodies.binding.value.ValueHolder;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.FormLayout;

public class ValueHolderExample extends JPanel {
    private ValueHolder valueHolder;

    public ValueHolderExample() {
        DefaultFormBuilder defaultFormBuilder = new DefaultFormBuilder(new FormLayout("p, 2dlu, p:g"));
        defaultFormBuilder.setDefaultDialogBorder();

        this.valueHolder = new ValueHolder("Text Value");
        JTextField textField = BasicComponentFactory.createTextField(valueHolder);

        defaultFormBuilder.append("TextField: ", textField);
        defaultFormBuilder.append(new JButton(new ShowValueHolderValueAction())3);

        add(defaultFormBuilder.getPanel());
    }

    private class ShowValueHolderValueAction extends AbstractAction {
        public ShowValueHolderValueAction() {
            super("Show Value");
        }

        public void actionPerformed(ActionEvent event) {
            StringBuffer message = new StringBuffer();
            message.append("<html>");
            message.append("<b>Value:</b> ");
            message.append(valueHolder.getValue());
            message.append("</html>");

            JOptionPane.showMessageDialog(null, message.toString());
        }
    }


    public static void main(String[] a){
      JFrame f = new JFrame("ValueHolder Example");
      f.setDefaultCloseOperation(2);
      f.add(new ValueHolderExample());
      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: Abstract Table Model ExampleJGoodies Binding: Abstract Table Model Example
10. JGoodies Binding: Basic Component Factory ExampleJGoodies Binding: Basic Component Factory Example
11. JGoodies Binding: Bean Adapter ExampleJGoodies Binding: Bean Adapter Example
12. JGoodies Binding: Bounded Range Adapter ExampleJGoodies Binding: Bounded Range Adapter Example
13. JGoodies Binding: Buffering Presentation Model ExampleJGoodies Binding: Buffering Presentation Model Example
14. JGoodies Binding: ComboBox Adapter ExampleJGoodies Binding: ComboBox Adapter Example
15. JGoodies Binding: Converter Factory ExampleJGoodies Binding: Converter Factory Example
16. JGoodies Binding: Feed Bean Example 1JGoodies Binding: Feed Bean Example 1
17. JGoodies Binding: Feed Bean Example 2JGoodies Binding: Feed Bean Example 2
18. JGoodies Binding: Feed Bean Example 3JGoodies Binding: Feed Bean Example 3
19. JGoodies Binding: Presentation Bean Channel ExampleJGoodies Binding: Presentation Bean Channel Example
20. JGoodies Binding: Presentation Bean Property Change Listener ExampleJGoodies Binding: Presentation Bean Property Change Listener Example
21. JGoodies Binding: Presentation Model Property Change ExampleJGoodies Binding: Presentation Model Property Change Example
22. JGoodies Binding: Property Adapter Example 1JGoodies Binding: Property Adapter Example 1
23. JGoodies Binding: Property Adapter Example 2JGoodies Binding: Property Adapter Example 2
24. JGoodies Binding: Property Adapter Example 3JGoodies Binding: Property Adapter Example 3
25. JGoodies Binding: Property Connector ExampleJGoodies Binding: Property Connector Example
26. JGoodies Binding: Radio Button Adapter ExampleJGoodies Binding: Radio Button Adapter Example
27. Swingx: Swing Data BindingSwingx: Swing Data Binding
w__w_w__.___j___av_a___2__s._c__o_m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.