Example usage for javax.swing JToolBar getComponentCount

List of usage examples for javax.swing JToolBar getComponentCount

Introduction

In this page you can find the example usage for javax.swing JToolBar getComponentCount.

Prototype

public int getComponentCount() 

Source Link

Document

Gets the number of components in this panel.

Usage

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.utils.ActionComponentManager.java

/**
 * Check and add toolbar button.//from w ww.  jav  a 2s  .com
 *
 * @param toolBar the tool bar
 * @param button the button
 * @param toolBarIndex the tool bar index
 */
private synchronized void checkAndAddToolbarButton(JToolBar toolBar, JideButton button, int toolBarIndex) {
    // check component count of toolBar before adding button at toolBarIndex
    int componentCount = toolBar.getComponentCount();
    if (componentCount > toolBarIndex) {
        // add horizontal space if component count > 0
        if (componentCount > 0) {
            toolBar.add(Box.createHorizontalStrut(5));
        }
        toolBar.add(button, toolBarIndex);
    } else {
        toolBar.add(button, componentCount);
    }
}