Results 1 to 3 of 3
  1. #1
    tanvirtonu is offline Member
    Join Date
    Mar 2008
    Posts
    4
    Rep Power
    0

    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.
    Java 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.
    Java 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.
    Java 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??

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    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.

  3. #3
    tanvirtonu is offline Member
    Join Date
    Mar 2008
    Posts
    4
    Rep Power
    0

    Default

    Quote 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.

Similar Threads

  1. Getting the beans property at runtime.
    By tanvirtonu in forum New To Java
    Replies: 1
    Last Post: 07-09-2009, 02:04 AM
  2. Replies: 0
    Last Post: 06-25-2009, 05:28 AM
  3. How to make Beans Lazily-instantiating beans
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-30-2008, 10:10 AM
  4. How to make Beans Lazily-instantiating beans
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 09-26-2007, 08:41 PM
  5. where is the system.property
    By osval in forum Advanced Java
    Replies: 2
    Last Post: 08-06-2007, 03:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •