简体   繁体   English

可观察到的错误

[英]Observable error

What does the error "The method setChanged() from type Observable is not visible" mean? 错误“来自Observable类型的setChanged()方法不可见”是什么意思? I tried looking in the documentation and I didn't find anything for setting an observable object to visible. 我尝试查看文档,但没有发现任何将可观察对象设置为可见的内容。 Here is my code: 这是我的代码:

       Observable observable = new Observable();
       //adding a listener to a button 
       @Override
        public void actionPerformed(ActionEvent e) {

            observable.setChanged();
            observable.notifyObservers(Main.this);

        }
    });

As defined in the API , the method setChanged is protected, and so available only to the class/subclasses: 根据API的定义 setChanged方法是受保护的,因此仅适用于类/子类:

protected void setChanged()

If you want to notify the observers about a change, call notifyObservers . 如果要通知观察者有关更改,请致电notifyObservers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM