Java JButton Create makeButtonPanel(Vector names, ActionListener actionListener)

Here you can find the source of makeButtonPanel(Vector names, ActionListener actionListener)

Description

make Button Panel

License

Open Source License

Declaration

public final static JPanel makeButtonPanel(Vector<String> names, ActionListener actionListener) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JPanel;

public class Main {
    public final static JPanel makeButtonPanel(Vector<String> names, ActionListener actionListener) {
        JPanel pane = new JPanel();
        for (String s : names) {
            JButton b = makeButton(s, actionListener);
            pane.add(b);//w w w .j  a  v a  2s  .  co m
        }
        return pane;
    }

    /**
     * Return a button with action command set to name.
     * 
     * @param name
     * @param l
     * @return
     */
    public final static JButton makeButton(String name, ActionListener l) {
        JButton button = new JButton(name);
        button.addActionListener(l);
        button.setActionCommand(name);
        return button;
    }
}

Related

  1. makeButton(Action action)
  2. makeButton(String name, ActionListener l)
  3. makeButtonActLikeLabel(JButton button)
  4. makeButtonBar(int align, Component... comps)
  5. makeButtonFlat(AbstractButton button)
  6. makeIconButton(Icon icon, String tooltip)
  7. makeNavigationButton(String actionCommand, String toolTipText, String altText)
  8. makeRadioButton(String text, String actionCommand, ButtonGroup buttonGroup, boolean selected)
  9. makeToggleButton(final Object owner, final String id, final String altText, final int wpad, final int hpad)