Reputation: 44134
I'm adding a custom component to a JTabbedPane
. The title of the tab is determined by getName()
in the component. Now at some point the result of getName()
changes, but the tab title is not automatically refreshed (as can be expected). How can I make it so?
Upvotes: 3
Views: 242
Reputation: 692291
Each time your component's name is changed, it could throw a PropertyChangeEvent
. When the component is added to the tabbed pane, you could add a PropertyChangeListener
to the component, listening for changes of its name
property, and updating the tab name accordingly.
Don't forget to remove the listener when the component is removed from the tabbed pane, though.
Upvotes: 3