Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009, 02:15 AM
Member
 
Join Date: Mar 2008
Posts: 4
Rep Power: 0
tanvirtonu is on a distinguished road
Default Getting the beans property at runtime
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 at runtime??
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-09-2009, 03:03 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 5,968
Rep Power: 7
Fubarable is on a distinguished road
Default
Please do not multipost the same question in multiple fora as it needlessly splits up the discussion and is not fair to the volunteers here (and elsewhere). Please choose one thread and I'll delete the other. Also, if you've cross-posted this question elsewhere, it will pay off dividends of good will if you are up front about it and post links. Thank you for your cooperation.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-09-2009, 11:31 AM
Member
 
Join Date: Mar 2008
Posts: 4
Rep Power: 0
tanvirtonu is on a distinguished road
Default
Originally Posted by Fubarable View Post
Please do not multipost the same question in multiple fora as it needlessly splits up the discussion and is not fair to the volunteers here (and elsewhere). Please choose one thread and I'll delete the other. Also, if you've cross-posted this question elsewhere, it will pay off dividends of good will if you are up front about it and post links. Thank you for your cooperation.
Actually I couldn't realize which topic my post should belong to.I m sorry though.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the beans property at runtime. tanvirtonu New To Java 1 07-09-2009 03:04 AM
Be Elite Join Property Elite , Property Realtor Needed , Career With Us - mindyyong Jobs Offered 0 06-25-2009 06:28 AM
How to make Beans Lazily-instantiating beans Java Tip Java Tips 0 03-30-2008 11:10 AM
How to make Beans Lazily-instantiating beans JavaBean Java Tips 0 09-26-2007 09:41 PM
where is the system.property osval Advanced Java 2 08-06-2007 04:54 AM


All times are GMT +2. The time now is 05:27 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org