Mega Code Archive

 
Categories / Java / Swing JFC
 

Get the index of the tab by matching the child component

import javax.swing.JButton; import javax.swing.JTabbedPane; public class Main {   public static void main(String[] argv) throws Exception {     JTabbedPane pane = new JTabbedPane();     JButton component = new JButton("button");     int index = pane.indexOfComponent(component);     if (index < 0) {       // The tab could not be found     }   } }