ButtonPanel.java
dw_fluffos_v1/lib/d/admin/mapper/31-10-01/mapmaker/ButtonPanel.java · 1.1 KB
From the archive dw_fluffos_v1.tar.gz
Download the archive « Back to the archive contents
package mapmaker;
import java.awt.*;
import java.util.*;
import javax.swing.*;
public class ButtonPanel extends JPanel
{
JPanel mSizePanel;
Vector mComponents = new Vector();
int mPixelWidth = 6;
public ButtonPanel()
{
super(new FlowLayout(FlowLayout.RIGHT, 0, 0));
mSizePanel = new JPanel(new GridLayout(1, 0, mPixelWidth - 1, 0));
add(mSizePanel);
}
public ButtonPanel(int aPixelWidth)
{
super(new FlowLayout(FlowLayout.RIGHT, 0, 0));
mPixelWidth = aPixelWidth;
mSizePanel = new JPanel(new GridLayout(1, 0, mPixelWidth - 1, 0));
add(mSizePanel);
}
/**
* This method adds buttons in reverse, so that additional buttons which
* are added appear to the left of the Okay and Cancel buttons.
*
* @param aButton the button to add
*/
public void addButton(Component aButton)
{
mComponents.addElement(aButton);
mSizePanel.removeAll();
for (int i = mComponents.size() - 1; i >= 0; i--)
{
mSizePanel.add((Component)mComponents.elementAt(i));
}
}
}