Steve
Steve

Reputation: 17

Change label of current panel in tabbed pane

I need to change the label of the currently selected tab in tabbed pane. It is for when the user saves the file the change must be reflected in the label of the current panel in the tabbed pane.

Tried a few things like:

 tabbedPane.setSelectedComponent(this.panel1.setName(name));

but no good

Upvotes: 0

Views: 140

Answers (1)

tbodt
tbodt

Reputation: 17017

A very simple line of java code will do this:

tabbedPane.setTitleAt(tabbedPane.getSelectedIndex(), newTabLabel);

This could be easily figured out from the Java API for JTabbedPane.

Upvotes: 3

Related Questions