Here you can find the source of isToolBarButton(JComponent c)
static boolean isToolBarButton(JComponent c)
//package com.java2s; //License from project: Open Source License import javax.swing.JComponent; import javax.swing.JToolBar; public class Main { /**/*from w w w . ja va2 s. c o m*/ * Returns true if the specified widget is in a toolbar. */ static boolean isToolBarButton(JComponent c) { return c.getParent() instanceof JToolBar; } }