Guest User

Untitled

a guest
Jan 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Observer;
  2. import java.util.Observable;
  3. public class TextObserver implements Observer
  4. {
  5.    String fieldname = null;
  6.    private SubjectValue sv = null;
  7.    
  8.    public TextObserver(String fieldname, SubjectValue sv)
  9.    {
  10.       this.fieldname = fieldname;
  11.       this.sv = sv;
  12.    }
  13.    
  14.    public void update(Observable obs, Object obj)
  15.    {
  16.       if (obs == sv)
  17.       {
  18.          if (this.fieldname == "text2")
  19.          {
  20.              ....setText2(sv.getValue()); // set text to a textfield in the main class
  21.          }
  22.          else if (this.fieldname == "text3")
  23.          {
  24.              ....setText3(sv.getValue()); // set text to a textfield in the main class
  25.          }
  26.       }
  27.    }
  28. }
Add Comment
Please, Sign In to add comment