【发布时间】:2010-10-15 02:32:12
【问题描述】:
我正在尝试在我的 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();
}
所以我需要知道我应该添加什么来使组件更新为新标题
【问题讨论】:
-
粘贴您用于更新标题的代码。使用 4 个空格进行自动格式化。
标签: java eclipse user-interface components jinternalframe