Question

i am trying to update the title of a JInternalFrame component in my Java Project.

The component is an instance of my ImageFrame class which extends JInternalFrame, and in my code I call a setter method in my ImageFrame class which updates the title attribute. I ran a Unit test and know that the attribute is updating properly, but I can't figure out how to refresh the component to show the new title.

Any Ideas?

FYI: I was unable to get .repaint() to do the trick.

Here's the Code:

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();
}

so what I need here is to know what I should add to make the component update with the new title

Was it helpful?

Solution

You could try by replacing:

frame.setFileName(selectedFile.getName());

with

 frame.setTitle(selectedFile.getName());

I don't know your code, but setFileName is not part of JInternalFrame public interface.

Probably you added that method, probably not. Try my suggestion and see if that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top