views:

72

answers:

2

If I create a Netbeans form, with say a bunch of string fields, how can I make the contents of the form fields automatically populate the class(object) I want to back the form?

+1  A: 

A NetBeans "form" is actually just a displayable Swing or AWT container class which you populate with components, like JTextField objects.

Components like JTextField already have a sort of backing store: their model. For example, for a JTextField object, there is an associated Document that can be retrieved by calling JTextField.getDocument.

Do you mean to move and unify the data from the Swing models and apply it to an application-level model of your own contrivance? NetBeans won't do that for you. Framed in the Model-View-Controller scheme, you have to design and implement your own controller.

Noel Ang
yeah, i do mean I want to use my object as the model backing the various components instead of their models.
Zak
Right. The GUI/form designer falls short of that level of abstraction.
Noel Ang
+1  A: 

If I understand it correctly you need a beans binding library (which automatically updates the UI on model changes and updates the model on user input). Take a look at the beansbinding library, better beans binding or this question.

If you want to investigate new frameworks which can do this out-of-the-box you could investigate griffon, spring-rich-client or some frameworks from this list

Karussell