Java JToolBar buildToolbar(final JToolBar toolbar, final List components)

Here you can find the source of buildToolbar(final JToolBar toolbar, final List components)

Description

Add a List of Components to the specified JToolBar.

License

Open Source License

Parameter

Parameter Description
toolbar a parameter
components a parameter

Declaration


public static void buildToolbar(final JToolBar toolbar, final List<Component> components) 

Method Source Code


//package com.java2s;
// it under the terms of the GNU General Public License as published by

import javax.swing.*;
import java.awt.*;

import java.util.Iterator;
import java.util.List;

public class Main {
    /***********************************************************************************************
     * Build a new JToolbar and add a List of Components.
     * Never returns NULL./*from   www. j  a v  a  2s . c  o m*/
     *
     * @param components
     *
     * @return JToolBar
     */

    public static JToolBar buildToolbar(final List<Component> components) {
        final JToolBar toolbar;

        toolbar = new JToolBar();

        // Build the Toolbar using the Components, if any
        // If the List is empty, we assume the User doesn't want any buttons...
        buildToolbar(toolbar, components);

        return (toolbar);
    }

    /***********************************************************************************************
     * Add a List of Components to the specified JToolBar.
     * Never returns NULL.
     *
     * @param toolbar
     * @param components
     */

    public static void buildToolbar(final JToolBar toolbar, final List<Component> components) {
        // Build the Toolbar using the Components, if any
        // If the List is empty, we assume the User doesn't want any buttons...

        if ((toolbar != null) && (components != null) && (!components.isEmpty())) {
            final Iterator<Component> iterComponents;

            iterComponents = components.iterator();

            while (iterComponents.hasNext()) {
                final Component component;

                component = iterComponents.next();

                if (component != null) {
                    toolbar.add(component);
                }
            }
        }
    }
}

Related

  1. addRadioButton(Container container, String label, int mnemonic, String tooltip, String placement, boolean debug)
  2. addToolbar(JPanel panel, JToolBar bar)
  3. addToolBarButton(JToolBar toolbar, Action action, String tooltip, Icon icon)
  4. addToolBarButton(JToolBar toolbar, Action action, String tooltip, Icon icon, String lbl)
  5. addToolItems(JToolBar toolBar, JComponent... items)
  6. createDefaultToolBar()
  7. createToolBar()
  8. createToolbar()
  9. fixButton(AbstractButton button, String toolTip)