Class ButtonLayout
java.lang.Object
|
+----ButtonLayout
- public abstract class ButtonLayout
- extends Object
Handles the layout of buttons at a specified height in the frame.
This will put a button named "done" at the bottom right of the window
and any number of buttons at the bottom left and top left, as spcified
in addButton().
- Author:
- Peter Sagerson, petersag@wpi.edu
-
bottomButtons
- The list of buttons on the left.
-
BUFFER
-
-
BUTTON_BUFFER
-
-
BUTTON_HEIGHT
-
-
BUTTON_WIDTH
-
-
done
- The done button.
-
frame
- The dimensions of the frame itself.
-
margin
- The margin around the window.
-
nBottom
- Number of buttons that have been added.
-
nTop
- Number of buttons that have been added.
-
topButtons
- The list of buttons on the left.
-
ButtonLayout(int, int)
- Creates
buttons and initializes n and
margin.
-
addButton(String, Component)
- Adds a button to the list (or adds the done button).
-
calcDimensions(Container)
- Calculates
frame and margin.
-
layoutButtons(Container, int)
- Lays out the buttons in the frame.
-
removeButton(Component)
-
BUFFER
protected static final int BUFFER
BUTTON_BUFFER
protected static final int BUTTON_BUFFER
BUTTON_HEIGHT
protected static final int BUTTON_HEIGHT
BUTTON_WIDTH
protected static final int BUTTON_WIDTH
nTop
int nTop
- Number of buttons that have been added.
nBottom
int nBottom
- Number of buttons that have been added.
topButtons
Component topButtons[]
- The list of buttons on the left.
bottomButtons
Component bottomButtons[]
- The list of buttons on the left.
done
Component done
- The done button.
margin
protected Insets margin
- The margin around the window. Computed in
calcDimensions().
frame
protected Dimension frame
- The dimensions of the frame itself.
ButtonLayout
ButtonLayout(int inTop,
int inBottom)
- Creates
buttons and initializes n and
margin.
- Parameters:
- numButtons - the number of buttons that will be added.
addButton
public void addButton(String name,
Component c)
- Adds a button to the list (or adds the done button). Buttons
other than the done button should be added from left to right
as you want them to appear. The done button is named "done".
Other buttons are named "bottom" or "top", depending on where you
want them to go.
removeButton
public void removeButton(Component c)
calcDimensions
protected void calcDimensions(Container parent)
- Calculates
frame and margin. Subclasses should
override this method, but call this one at the beginning of the new one.
layoutButtons
public void layoutButtons(Container parent,
int bottomHeight)
- Lays out the buttons in the frame.