Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Observer;
- import java.util.Observable;
- public class TextObserver implements Observer
- {
- String fieldname = null;
- private SubjectValue sv = null;
- public TextObserver(String fieldname, SubjectValue sv)
- {
- this.fieldname = fieldname;
- this.sv = sv;
- }
- public void update(Observable obs, Object obj)
- {
- if (obs == sv)
- {
- if (this.fieldname == "text2")
- {
- ....setText2(sv.getValue()); // set text to a textfield in the main class
- }
- else if (this.fieldname == "text3")
- {
- ....setText3(sv.getValue()); // set text to a textfield in the main class
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment