java.util.Observable.setChanged()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中java.util.Observable.setChanged()方法的一些代码示例,展示了Observable.setChanged()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.setChanged()方法的具体详情如下:
包路径:java.util.Observable
类名称:Observable
方法名:setChanged

Observable.setChanged介绍

[英]Sets the changed flag for this Observable. After calling setChanged(), hasChanged() will return true.
[中]设置此可观察对象的已更改标志。调用setChanged()后,hasChanged()将返回true。

代码示例

代码示例来源:origin: org.apache.poi/poi

void checkForLocaleChange(Locale newLocale) {
    if (!localeIsAdapting) return;
    if (newLocale.equals(locale)) return;
    super.setChanged();
    notifyObservers(newLocale);
  }
}

代码示例来源:origin: plutext/docx4j

void checkForLocaleChange(Locale newLocale) {
    if (!localeIsAdapting) return;
    if (newLocale.equals(locale)) return;
    super.setChanged();
    notifyObservers(newLocale);
  }
}

代码示例来源:origin: stackoverflow.com

import java.util.Observable;

public class Flux extends Observable {
 private int someVariable = 0;

 public void setSomeVariable(int someVariable) {
  synchronized (this) {
   this.someVariable = someVariable;
  }
  setChanged();
  notifyObservers();
 }

 public synchronized int getSomeVariable() {
  return someVariable;
 }
}

代码示例来源:origin: Dreampie/Resty

public void doNotify() {
 logger.error("ReloadRunnable is dead.");
 try {
  if (!Thread.currentThread().isInterrupted()) {
   Thread.sleep(restartInterval);
  }
 } catch (InterruptedException e) {
  logger.error(e.getMessage(), e);
 }
 super.setChanged();
 notifyObservers();
}

代码示例来源:origin: stackoverflow.com

public class ObservableObject extends Observable {
  private static ObservableObject instance = new ObservableObject();

  public static ObservableObject getInstance() {
    return instance;
  }

  private ObservableObject() {
  }

  public void updateValue(Object data) {
    synchronized (this) {
      setChanged();
      notifyObservers(data);
    }
  }
}

代码示例来源:origin: stackoverflow.com

setChanged();
notifyObservers();

代码示例来源:origin: stackoverflow.com

setChanged();
notifyObservers();
setChanged();
notifyObservers(guess.equals(hidden));

代码示例来源:origin: stackoverflow.com

public class FilterManager extends Observable {
  private String query;

  public void setQuery(String query) {
    this.query = query;
    setChanged();
    notifyObservers();
  }

  public String getQuery() {
    return query;
  }
}

代码示例来源:origin: stackoverflow.com

Observable observable = observables.get(notification);
if (observable!=null) {
  observable.setChanged();
  observable.notifyObservers(object);

代码示例来源:origin: stackoverflow.com

setChanged();
notifyObservers();

代码示例来源:origin: stackoverflow.com

setChanged();
notifyObservers();

代码示例来源:origin: org.apache.directory.api/api-ldap-model

@Override
  public void setChanged()
  {
    super.setChanged();
  }
}

代码示例来源:origin: stackoverflow.com

import java.util.Observable;
 public class Keybaord extends Observable {
   private String keyThatIsPressed;
   public void setKeyThatIsPressed(String keyThatIsPressed) {
     this.keyThatIsPressed = keyThatIsPressed;
     setChanged();
     notifyObservers(keyThatIsPressed);
   }
   public String getKeyThatIsPressed(){
     return keyThatIsPressed;
   }
}

代码示例来源:origin: stackoverflow.com

public class Aminal extends Observable {
  public void doSomethingThatNotifiesObservers() {
    setChanged();
    notifyObservers(new Integer(42));
  }
}

代码示例来源:origin: stackoverflow.com

import java.util.Observable;

public class DataModel extends Observable
{
  public void retrieveData()
  {
    // ...

    setChanged();
    notifyObservers(); // or notifyObservers(someData);
  }
}

代码示例来源:origin: stackoverflow.com

@Service
public class MyServiceImpl extends Observable implements MyService {

  @Override
  public void manageResponse(String response) {

   this.setChanged();
   this.notifyObservers(response);               
  }
}

代码示例来源:origin: stackoverflow.com

class DaoUser extends Observable {
 //other methods
 public User findUsers (int id_user) {
  //find your user. Once you find it
  setChanged();
  notifyObservers(user_found);
 }
}

代码示例来源:origin: stackoverflow.com

public class ObservableStream extends Observable {
  private final Queue<String> lines = new ConcurrentLinkedQueue<>();

  public void addLine(String line) {
    lines.add(line);
    setChanged();
    notifyObservers();
  }

  public String nextLine() {
    return lines.poll();
  }
}

代码示例来源:origin: stackoverflow.com

public class Model extends Observable {
  public void transform() {

    // Do the transformation

    // notify the view
    setChanged();
    notifyObservers();
  }
}

代码示例来源:origin: stackoverflow.com

public class BroadcastObserver extends Observable {
  private void triggerObservers() {
    setChanged();
    notifyObservers();
  }

  public void change() {
    triggerObservers();
  }
}

相关文章