About

PgsBindings enables you to easily bind a Swing component to an Map (this includes Properties - that might be the main audience) or any bean.

However, it also enables you to validate the contents of Swing components (currently only JTextComponent and subclasses are supported).

It has been build to be extremly extensible, powerfull and easy to use.

Read the developers guide, the JavaDocs and take a look at its source code to get started.

Most of it's features are very easy to use and the required source code is really small.

It is released under the Apache Software License, so you can use it even in commercial software without any restrictions.

Download PgsBindings 0.4 now or take a look at the developers guide.

"HelloWorld"-Sample

If you don't want to read the 12 pages long developers guide without knowing what you'll get, here's a very brief sample (though it isn't the simplest possible):

  1. // Some bean
  2. public class Customer {
  3.     private String name;
  4.     private String phone;
  5.    
  6.     // Constructor/Getters/Setters ommited
  7. }
  8.  
  9. // Create bean and binder
  10. Customer customer = new Customer();
  11. SwingBinder binder = new SwingBinder(new BeanMap(customer));
  12.  
  13. // Create some textfields
  14. JTextField name = new JTextField();
  15. JTextField phone = new JTextField();
  16.  
  17. // bind them (and add validation
  18. binder.bind("name", name, "[a-zA-Z- ]");
  19. binder.bind("phone", phone, "[0-9]");
  20.  
  21. // show the form and invoke code below if the user submits
  22. if(binder.validate().isValid()) {
  23.     binder.save();
  24.     // starting from this point all form-data was written to our bean
  25. } else {
  26.     // you can get all invalid components and highlight them somehow
  27.     // this is just a brief intro so we'll skip it
  28. }
  29.