NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Getting the beans property at runtime.

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
tanvirtonu



Joined: 14 May 2009
Posts: 21

PostPosted: Tue Jul 07, 2009 11:14 pm    Post subject: Getting the beans property at runtime. Reply with quote

I have made a bean component automatically created by netbeans.Then I bind a jtextfield's text property to that bean's property and in my main method I set the property for that bean.Yet, I m not getting the property name in my textfield after the program runs.Can anybody help.
Here is the bean component that netbeans created for me by default.
Code:
package saraelectro;
import java.beans.*;
import java.io.Serializable;
public class myBean implements Serializable {

    public static final String PROP_SAMPLE_PROPERTY = "sampleProperty";

    private String sampleProperty;

    private PropertyChangeSupport propertySupport;

    public myBean() {
        propertySupport = new PropertyChangeSupport(this);
    }

    public String getSampleProperty() {
        return sampleProperty;
    }

    public void setSampleProperty(String value) {
        String oldValue = sampleProperty;
        sampleProperty = value;
        propertySupport.firePropertyChange(PROP_SAMPLE_PROPERTY, oldValue, sampleProperty);
    }


    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }

}

This is my main method to set the property of that bean.
Code:
public static void main(String[] args) {
       myBean bn= new myBean();
       bn.setSampleProperty("This text should go into the jtextfield");
       myFrame frm=new myFrame();
       frm.setVisible(true);
      }

And that is what netbeans created after I bound jtextfield's text property to my beans' property.
Code:
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, myBean1, org.jdesktop.beansbinding.ELProperty.create("${sampleProperty}"), myTextField, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

WHY am I not getting that value of my bean in my textfield??
Back to top
Jose



Joined: 29 Apr 2010
Posts: 2

PostPosted: Thu Apr 29, 2010 8:40 am    Post subject: Same problem Reply with quote

Hi! I have the same problem.. did you find any solution?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo