[英]How to update a JFrame from another JFrame in java
我想从另一个JFrame更新一个JFrame。 我有一个基本程序,该程序具有两个具有相同组名的相似接口,我想知道如何编写该程序,因此,如果一个人更改了组名,它将自动在另一个上更改。
提前致谢
第一个界面
Public String groupNam;
private void groupNActionPerformed(java.awt.event.ActionEvent evt) {
interface2 interface2 = new interface2();
groupNam = groupN.getText();
interface2.group.equals(groupNam); //interface2 is the class name of the other interface
}
第二介面
private void groupNameActionPerformed(java.awt.event.ActionEvent evt) {
groupName.getText().equals(groupNam); //calling the public string from interface 1 and placing it in groupName field
}
这是我的尝试,但是没有用。
您听说过观察者模式吗?
这可能是您的正确选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.