Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3432230
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:25:24+00:00 2026-05-18T07:25:24+00:00

In order to understand how JFace databindings is working, I have a model object

  • 0

In order to understand how JFace databindings is working, I have a model object with two properties. Changing one property should set the other to the same value:

public class Model {
  private double x;
  private double y;
  private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public void addPropertyChangeListener(String propertyName,
            PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
    }

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

    public void setX(double x) {
        propertyChangeSupport.firePropertyChange("x", this.x, this.x = x);
    }

    public double getX() {
        return x;
    }

    public void setY(double y) {
        propertyChangeSupport.firePropertyChange("y", y, this.y = y);
        setX(y);
    }

    public double y() {
        return y;
    }
}

Now in a separate class I define two Text widgets, xText and yText, which are bound to this object like this:

    DataBindingContext bindingContext = new DataBindingContext();
    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(xText),
            BeanProperties.value(HumidityScanParameters.class,"x").observe(getModel()));
    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(yText),
            BeanProperties.value(HumidityScanParameters.class, "y").observe(getModel()));

I have found that if I change the text in yText, then the setter is automatically called as expected, and this sets both y and x in the model. However, xText is not updated. Why is this? Shouldn’t the firePropertyChange() call arrange for the Text to be updated?

Thanks,
Graham.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:25:25+00:00Added an answer on May 18, 2026 at 7:25 am

    The compiler was optimising away the initial value of this.x and this.y, which led the PropertyChangeSupport instance to discard the change notification. It didn’t think anything had changed. If I introduce a temporary variable like this:

    public void setX(double x) {
        double oldValue = this.x;
        this.x = x;
        propertyChangeSupport.firePropertyChange("x", oldValue, x);
    }
    

    then the notifications occur as I might expect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should I save the phone model on my database in order to understand my
I have a homework question regarding operator precedence in Fortran. In order to understand
In order to understand the Monitor I have implemented the following code.But I am
I'm working on creating a simple MCV application, in order to understand MVC better.
I have made a small example in order to understand how boost::bind () works
Some projects are so big that in order to understand for example a function
I am using an NSLog statement in order to understand when -applicationDidBecomeActive: gets called,
I understand pre-order, in-order, and post-order tree traversal algorithms just fine. ( Reference ).
I understand that Haskell's filter is a high order function (meaning a function that
I want to understand in which order are the elements of h_addr_list sorted when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.