Example usage for javax.swing JTabbedPane remove

List of usage examples for javax.swing JTabbedPane remove

Introduction

In this page you can find the example usage for javax.swing JTabbedPane remove.

Prototype

public void remove(int index) 

Source Link

Document

Removes the tab and component which corresponds to the specified index.

Usage

From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java

private void adjustTabbedPanes(List<JTabbedPane> lst) {
    for (JTabbedPane tabPane : lst) {
        List<Component> lstTabToRemove = new ArrayList<Component>(tabPane.getTabCount());
        for (int i = 0; i < tabPane.getTabCount(); i++) {
            Component c = tabPane.getComponentAt(i);
            if (c instanceof JComponent) {
                List<JComponent> lstComponents = new ArrayList<JComponent>();
                collectComponents((JComponent) c, lstComponents);
                if (lstComponents.size() == 0) {
                    tabPane.setEnabledAt(i, false);
                    lstTabToRemove.add(c);
                    break;
                }/*from  w ww.  j a  va2s  .c  om*/

                boolean blnVisible = false;
                for (JComponent jc : lstComponents) {
                    if (jc instanceof LabeledComponent) {
                        LabeledComponent lc = (LabeledComponent) jc;
                        blnVisible = lc.isVisible();
                    } else if (jc instanceof JPanel)
                        blnVisible = false;
                    else
                        blnVisible = jc.isVisible();
                    if (blnVisible)
                        break;
                }

                tabPane.setEnabledAt(i, !blnVisible ? blnVisible : blnVisible && tabPane.isEnabledAt(i));
                if (!blnVisible)
                    lstTabToRemove.add(c);
            }
        }
        for (Component c : lstTabToRemove) {
            tabPane.remove(c);
        }
    }
}