Reputation: 323
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
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