How do you make a Netbeans form automatically populate fields in a class?
If I create a Netbe开发者_开发百科ans 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?
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
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.
精彩评论