GridBagLayout bag;
GridBagConstraints c;
+ /* Create a panel with a bag layout. Create some constraints are
+ users can modify prior to creating widgets - the current constraints
+ will be applied to all widgets created with makeXXX */
public BagPanel() {
bag = new GridBagLayout();
setLayout(bag);
c = new GridBagConstraints();
}
+ /* The makeXXX methods create XXX widgets, apply the current constraints
+ to them, and add them to this panel. The widget is returned in case
+ the creator needs to hang on to it. */
+
public JButton makeButton(String label, ActionListener action) {
JButton button = new JButton();
button.setText(label);
return tf;
}
- public void addSeparator(int axis) {
+ public JSeparator makeSeparator(int axis) {
JSeparator sep = new JSeparator(axis);
bag.setConstraints(sep, c);
add(sep);
+ return sep;
}
}