将更改通知 "remote" JComponent

Notify a "remote" JComponent about a change

考虑如下的 JPanel 结构:

MainPanel 包含两个面板:AdminPanel 和 ReportPanel。
AdminPanel 包含 SetupPanel,后者包含 LogoPanel。

我想通知 ReportPanel LogoPanel 的某些更改。
为此,我在 ReportsPanel 中实现了 属性-change listener。我在 ReportsPanel 中也有一个对自身的静态引用。
LogoPanel 使用此静态引用调用 listener
这个解决方案有效,但对我来说似乎并不优雅。

我的问题:有更优雅的方法吗?

我制定的解决方案如下:
创建了一个简单的界面

    public interface Follower {

        public void changed(String property);
    }


和一个 监听器 class :

    public class LogoListener  {

        /**
         * A static reference to this.
         */
        private static LogoListener listener;

        /**
         * Represents the objects to be notified by the listener.
         */
        private static List<Follower> followers;

        /**
         * Create a simple listener to be used by one "notifying"
         * object, and "followers" objects.
         *
         */
        private LogoListener() {
            followers = new ArrayList<Follower>();
            listener = this;
        }

        /**
         * Method to be used by the "notifying" object, to
         * notify followers.
         */
        public void notifyFollowers() {

            for(Follower follower : followers){
                follower.changed("Logo changed");
            }

            System.out.println("Logo changed");

        }

        /**
         * Get the listener instance, or create one if it does not exist.
         *
         * @return the listener
         *              
         */
        public static LogoListener getListener() {

            if(listener == null) {
                listener = new LogoListener();
            }
            return listener;
        }

        /**
         *
         * @param follower
         *       <br>Not null.
         * @throws
         *      <br>IllegalArgumentException if <code>follower</code> is   null.
         */
         public void addFollower(Follower follower) {

            if(follower == null ) {
                throw new
                    IllegalArgumentException("Follower should not be null");
            }

            followers.add(follower);
        }

    }


Reports 面板("follower" 或监听对象)实现 Follower 接口,简单来说就是重写 changed(String message) 方法:

        /* (non-Javadoc)
         * @see listener.Follower#changed(java.lang.String)
         */
        @Override
        public void changed(String msg ) {
            //respond to change goes here 
            System.out.println(msg);

        }


并通过以下方式注册为关注者:

            LogoListener.getListener()
                        .addFollower(this);


徽标面板 通过以下方式通知更改:

        LogoListener listener = LogoListener.getListener();
        listener.notifyFollowers();


欢迎交流和反馈。