package com.explodingpixels.macwidgets;
import java.awt.FlowLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
/**
* Creates a group of components and provides a label underneath those components. The added
* components will be placed side by side, with no spacing in between them, like this:
*
*
*
* Here are a couple more practical applications of {@code LabledComponentGroup}:
*
*
*
* Here's how to create a {@code LabeledComponentGroup} with two buttons:
*
* JToggleButton leftButton = new JToggleButton("Left Button"); * leftButton.putClientProperty("JButton.buttonType", "segmentedTextured"); * leftButton.putClientProperty("JButton.segmentPosition", "first"); * * JToggleButton rightButton = new JToggleButton("Right Button"); * rightButton.putClientProperty("JButton.buttonType", "segmentedTextured"); * rightButton.putClientProperty("JButton.segmentPosition", "last"); * * LabeledComponentGroup group = new LabeledComponentGroup("Group", leftButton, rightButton); **/ public class LabeledComponentGroup { private JComponent fComponent; /** * Creates a labeled component group using the given label and components. * * @param labelString the label of the group. * @param components the components in the group. */ public LabeledComponentGroup(String labelString, JComponent... components) { this(labelString, Arrays.asList(components)); } /** * Creates a labeled component group using the given label and components. * * @param labelString the label of the group. * @param components the components in the group. */ public LabeledComponentGroup(String labelString, List