I have started working on a client container project. Its goal is to simplify swing developement, by leveraging an Inversion of Control (IoC) container, Picocontainer, and Java 5.0 annotations, and the JGoodies libraries.
Version 0.1 has been released, and there is a little demo where you can test it and see how it works. Please help me on this project by providing feedback and ideas.
http://sourceforge.net/projects/clicoLudovic
---
Sample code:
@VisualFeedback({VisualClue.MANDATORY_BACKGROUND})
@Localisation(resource="customer_view")
public class CustomerView extends JPanel {
@Required
@StringValidation(lengthMoreThan=2, lengthLessThan=8, format="
w*")
private JTextField name = new JTextField();
@Required
private JTextField company = new JTextField();
@TypeValidation("email")
private JFormattedTextField email = new JFormattedTextField();
@TypeValidation("phone")
private JFormattedTextField phone = new JFormattedTextField();
private JLabel nameResult = new JLabel();
private JLabel companyResult = new JLabel();
private JLabel emailResult = new JLabel();
private JLabel phoneResult = new JLabel();
private JButton save = new JButton();
@Init
public void initActions(CloseAction closeAction) {
save.setAction(closeAction);
}
@Init
public void initBindings(BeanBinder bb) {
bb.bind(name, Customer.PROPERTYNAME_NAME);
bb.bind(nameResult, Customer.PROPERTYNAME_NAME);
bb.bind(company, Customer.PROPERTYNAME_COMPANY);
bb.bind(companyResult, Customer.PROPERTYNAME_COMPANY);
bb.bind(email, Customer.PROPERTYNAME_EMAIL);
bb.bind(emailResult, Customer.PROPERTYNAME_EMAIL);
bb.bind(phone, Customer.PROPERTYNAME_PHONE);
bb.bind(phoneResult, Customer.PROPERTYNAME_PHONE);
}
@Init
public void initLayout(EasyFormLayout layout) {
layout.setColumns("right:max(50dlu;pref), 3dlu, 50dlu, 3dlu, 50dlu, 3dlu");
layout.setDefaultDialogBorder();
layout.printlnSeparator("Customer details");
layout.println("", name, nameResult);
layout.println("", company, companyResult);
layout.println("", email, emailResult);
layout.println("", phone, phoneResult);
}
}
public class Customer extends Model {
public static final String PROPERTYNAME_ADDRESS = "address";
public static final String PROPERTYNAME_NAME = "name";
public static final String PROPERTYNAME_COMPANY = "company";
public static final String PROPERTYNAME_PHONE = "phone";
public static final String PROPERTYNAME_EMAIL = "email";
private String name;
private String company;
private String phone;
private String email;
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
Address oldAddress = this.address;
this.address = address;
firePropertyChange(PROPERTYNAME_ADDRESS, oldAddress, address);
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
String oldCompany = this.company;
this.company = company;
firePropertyChange(PROPERTYNAME_COMPANY, oldCompany, company);
}
public String getName() {
return name;
}
public void setName(String name) {
String oldName = this.name;
this.name = name;
firePropertyChange(PROPERTYNAME_NAME, oldName, name);
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
String oldPhone = phone;
this.phone = phone;
firePropertyChange(PROPERTYNAME_PHONE, oldPhone, phone);
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
String oldEmail = this.email;
this.email = email;
firePropertyChange(PROPERTYNAME_EMAIL, oldEmail, email);
}
}