01: /*
02: ** $Id: ButtonView.java,v 1.7 2000/10/26 08:34:15 mrw Exp $
03: **
04: ** Mike Wilson, July 2000, mrw@whisperingwind.co.uk
05: **
06: ** (C) Copyright 2000, Mike Wilson, Reading, Berkshire, UK
07: **
08: ** This program is free software; you can redistribute it and/or modify
09: ** it under the terms of the GNU General Public License as published by
10: ** the Free Software Foundation; either version 2 of the License, or
11: ** (at your option) any later version.
12: **
13: ** This program is distributed in the hope that it will be useful,
14: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: ** GNU General Public License for more details.
17: **
18: ** You should have received a copy of the GNU Library General
19: ** Public License along with this library; if not, write to the
20: ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21: ** Boston, MA 02111-1307 USA.
22: */
23:
24: package uk.co.whisperingwind.framework;
25:
26: import java.awt.Container;
27: import java.awt.GridLayout;
28: import java.awt.GridBagLayout;
29: import java.awt.GridBagConstraints;
30: import java.awt.Insets;
31: import javax.swing.JFrame;
32: import javax.swing.JToolBar;
33:
34: /**
35: ** Dialog view with a row of buttons along the bottom. This doesn't
36: ** actually add any buttons, but it does prepare a panel to contain
37: ** them. The buttons are contained in sub-class of JToolBar as this is
38: ** the only way I can see to create a button from an Action.
39: */
40:
41: public abstract class ButtonView extends DialogView {
42: protected ButtonPanel buttonPanel = new ButtonPanel();
43:
44: /**
45: ** Construct a ButtonView with the specified frame as the parent.
46: **
47: ** @param parent parent frame.
48: ** @param modal true for a modal dialog, false for non-modal.
49: */
50:
51: public ButtonView(JFrame parent, boolean modal) {
52: super (parent, modal);
53: Container container = content.getContentPane();
54: container.setLayout(new GridBagLayout());
55: GridBagConstraints constraints = new GridBagConstraints();
56:
57: constraints.gridx = 0;
58: constraints.gridy = 1;
59: constraints.insets = new Insets(4, 4, 4, 4);
60: constraints.fill = GridBagConstraints.NONE;
61: constraints.weightx = 0.0;
62: constraints.weighty = 0.0;
63: constraints.anchor = GridBagConstraints.WEST;
64: container.add(buttonPanel, constraints);
65: }
66:
67: /**
68: ** Button panel has a grid layout so all the buttons are the same
69: ** size. This is best packed into a FlowLayout or a GridBagLayout
70: ** with no fill constraints. This is only used for a horizontal
71: ** row of buttons, eg at the bottom of a dialog.
72: */
73:
74: protected class ButtonPanel extends JToolBar {
75: public ButtonPanel() {
76: this .setLayout(new GridLayout(1, 0, 4, 4));
77: setFloatable(false);
78: }
79: }
80: }
|