Menu

Property Change Listener

Help
2014-03-04
2014-03-04
  • BjoernBeyer

    BjoernBeyer - 2014-03-04

    I am not quite sure weather I do not understand it correctly or weather the GUI update is broken.

    I have a filter with a property 'MaxMove' with the following getter/setter methods:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    public float getMaxMove(){
      return MaxMove;
    }
    
    public void setMaxMove(float MaxMove) {
      putFloat("MaxMove",MaxMove);
      float OldValue = this.MaxMove;
      this.MaxMove = MaxMove;
      support.firePropertyChange("MaxMove",OldValue,MaxMove);
    }
    

    As far as I understood the 'support.firePropertyChange' should cause the GUI to update the property whenever it is changed via the 'set' method in the background.
    However this update does not happen for me.

    For example when I add the line 'setMaxMove(0.9999f);' to the reset property of the filter and press the reset button the displayed value does not change.

    Do I have to register a Listener in the filter or do anything else such that the displayed property value changes automatically?
    I wanted to clarify here first before entering this as a new ticket.

     
  • Tobi Delbruck

    Tobi Delbruck - 2014-03-04

    Bjorn, you ran into another feature. If a property has a getMinX and getMaxX (or just one of these, apparently) then it is interpreted to make a slider for the property.
    Please rename your property from maxMove to maximumMove and it should fix it.

    There is a bug I guess where only one of these is needed.
    I haven't looked at code to see if this is really the case.

    All this stuff is in FilterPanel class.
    Let me know if that helps you out.
    Tobi

     
  • BjoernBeyer

    BjoernBeyer - 2014-03-04

    Good to hear about the slider feature! Didn't know about that.
    Infact however this was not the problem. For the slider to show up one needs the four methods: 'getXXX' , 'setXXX' , 'getMinXXX' , 'getMaxXXX'

    As it turns out my Problem was not a bug but in the line

    1
    2
    3
    support.firePropertyChange("MaxMove",
                                OldValue,
                                MaxMove);
    

    the property needs to be in lowercase as displayed in the GUI, not in Uppercase as in the methodname.
    The corrected code is:

    1
    2
    3
    support.firePropertyChange("maxMove",
                                OldValue,
                                MaxMove);
    

    I might be updating the Wiki in the next days so that all these cool ways of manipulating the GUI are easier to find.

    Thanks for you help Tobi!

     

    Last edit: BjoernBeyer 2014-03-04