我正在尝试更新我的 Java 项目中的 JInternalFrame 组件的标题。
该组件是我的 ImageFrame 类的一个实例,它扩展了 JInternalFrame,在我的代码中,我在我的 ImageFrame 类中调用了一个 setter 方法来更新 title 属性。我运行了一个单元测试并且知道该属性正在正确更新,但我不知道如何刷新组件以显示新标题。
有任何想法吗?
仅供参考:我无法让 .repaint() 做到这一点。
这是代码:
File selectedFile = fileChooser.getSelectedFile(); // Gets File selected in JFileChooser
try {
ImageReadWrite.write(img, selectedFile); // Writes Image Data to a File
frame.setFilePath(selectedFile.getAbsolutePath()); // Changes File Location Attribute in Instance Of ImageFrame
frame.setFileName(selectedFile.getName()); // Changes Window Title Attribute
//frame.??
}
catch (Exception event) {
event.printStackTrace();
}
所以我在这里需要知道我应该添加什么来使组件更新为新标题