不断更新GUI元素的最佳方法 [英] Best Way to Constantly Update GUI Elements

查看:102
本文介绍了不断更新GUI元素的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java GUI,其中包含许多文本字段,其值是从另一个类的静态变量中填充的.

I have a Java GUI that has a number of text fields, the values of which are populated from static variable in another class.

我想知道最好的方法是什么,以便在另一个类中更改变量时,更新立即反映在GUI上.

I am interested to know what the best way is to make it so that when the variable is changed in another class, the update is instantly reflected on the GUI.

如果有人可以提出有效的建议,将不胜感激.

If any one could make a suggestion on an efficient way to do this it would be highly appreciated.

非常感谢您的提前答复

其他详细信息

  • 使用Swing
  • 理想情况下,更新将是实时的

推荐答案

在我看来,明智的选择是在观察者模式.您可以找到关于该主题的许多示例,例如这个

In my opinion a wise choice is to implement it following the Observer Pattern. you can find plenty of examples on this topic like this

这篇关于不断更新GUI元素的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆