Gherkin in God mode
Gherkin in God mode

Reputation: 323

How to get title of current tab

How would one get the name of the active tab / JPanel within a JTabbedPane in order to compare it to a string? It is a simple question but I cannot find a solution to this.

Upvotes: 0

Views: 1093

Answers (1)

Horatiu Jeflea
Horatiu Jeflea

Reputation: 7434

With getSelextedIndex you get the index of the active tab and with getTitleAt you get the title of that index:

JTabbedPane tabbedPane ...
int selectedIndex = tabbedPane.getSelectedIndex();
tabbedPane.getTitleAt(selectedIndex);

Upvotes: 3

Related Questions