wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Netbeans binding problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Netbeans binding problem" Watch "Netbeans binding problem" New topic
Author

Netbeans binding problem

Marcel van der Ven
Greenhorn

Joined: Mar 20, 2010
Posts: 14
Hello,

I have a question about binding textfields to a source.
I want to make a user interface with a combo box where the user can select a company from the list and the data about that company will be shown in different JTextFields, the data in the JTextField is not editable, the screen is thus only to view the data.

I have tried to program this in Netbeans but I do not get the data into the textfields, I have bind the combobox to my company table from the database and I have created a instance of my company entity in the user interface, also I have bind every jTextField to the corresponding field in my company instance.
When the user selects a company an ActionPerformed event will get the Company object and copies this into my company instance.

Now when I start the application I get the company names from the database table in my combobox but I do not see the data in the JTextfields after I selected a Company.
If I use a setter on my company instance and set a attribute then the data will be updated directly, I know this is because the setter has a changeSupport.firePropertyChange statement in it.

The question is how can I fire this for every attribute in my company instance when I give my company instance a new reference from a list and without calling every setter from the instance?

Thanks in advance

Marcel
Marcel van der Ven
Greenhorn

Joined: Mar 20, 2010
Posts: 14
Is there anybody who can help me with this issue???
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> The question is how can I fire this for every attribute in my company instance when I give my company instance a new reference from a list and without calling every setter from the instance?

can't help with what I think you're getting at, but it just seems easy enough to load a Company object into the comboBox,
and on selection of a Company, load the textfields with that Company's data (from the combobox object itself)

you could possibly create a single getter that returns a String[] of the data, then populate a single row JTable (no header)
with the String[], which would look like a bunch of textfields together
Marcel van der Ven
Greenhorn

Joined: Mar 20, 2010
Posts: 14
Michael the solution you gave me is possibly, but what I am trying to do is, binding the textfields to the selection of the ComboBox (jComboBox2).
In this case the textfield are bind to a instance of a entity (company1), when the data in this instance change the data in the textfield also change. When the user selects a company, the entity instance is filled with the selected instance in the Combobox that is retrieved from the companyList. Then I do not have to manually program some function that gets the selection and populate every textfield.
Below is a small piece of the code in the initComponents() function:



The problem is, if I select a company and copy the selected company from the companyList to the company1 instance the setters that fire a PropertyChange will not be called and thus the PropertyChange will not be fired. Now the textfields do not know that the company1 instance where they are bind to is changed.
I can program a wrapper function that gets the instance from the companyList and fills the company1 instance by calling every setter from that instance, but there has to be some better solution???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Netbeans binding problem
 
Similar Threads
Bean Info And Netbeans IDE
How to bind a JList to a Bean class property
Identify a component that has been added by iteration
Netbeans Visual JSF Data Bindings to Table
"Casting" from a Superclass to a subclass