Source code: com/cybertivity/powerjournal/framework/ButtonView.java
1 /*
2 * Title: Similated Intelligence
3 * Copyright: Copyright (c) 2001 Cybertivity
4 * Company: <A HREF="http://www.cybertivity.com">Cybertivity</A>
5 * @author <A HREF="mailto:chris.arrowood@cybertivity.com">Chris Arrowood</A>
6 * @version $Id: ButtonView.java,v 1.1.1.1 2001/11/24 03:51:34 arrowood Exp $
7 */
8 package com.cybertivity.powerjournal.framework;
9
10 import java.awt.Container;
11 import java.awt.GridBagConstraints;
12 import java.awt.GridBagLayout;
13 import java.awt.GridLayout;
14 import java.awt.Insets;
15 import javax.swing.JFrame;
16 import javax.swing.JToolBar;
17
18 /**
19 * Description of the Class
20 *
21 * @author arrowood
22 * @created July 17, 2001
23 */
24 public abstract class ButtonView extends DialogView {
25 protected ButtonPanel buttonPanel = new ButtonPanel();
26
27
28 /**
29 * Construct a ButtonView with the specified frame as the parent.
30 *
31 * @param parent parent frame.
32 * @param modal true for a modal dialog, false for non-modal.
33 */
34
35 public ButtonView(JFrame parent, boolean modal) {
36 super(parent, modal);
37 Container container = content.getContentPane();
38 container.setLayout(new GridBagLayout());
39 GridBagConstraints constraints = new GridBagConstraints();
40
41 constraints.gridx = 0;
42 constraints.gridy = 1;
43 constraints.insets = new Insets(4, 4, 4, 4);
44 constraints.fill = GridBagConstraints.NONE;
45 constraints.weightx = 0.0;
46 constraints.weighty = 0.0;
47 constraints.anchor = GridBagConstraints.WEST;
48 container.add(buttonPanel, constraints);
49 }
50
51
52 /**
53 * Button panel has a grid layout so all the buttons are the same size. This
54 * is best packed into a FlowLayout or a GridBagLayout with no fill
55 * constraints. This is only used for a horizontal row of buttons, eg at the
56 * bottom of a dialog.
57 *
58 * @author arrowood
59 * @created July 17, 2001
60 */
61
62 protected class ButtonPanel extends JToolBar {
63 /**
64 * Constructor for the ButtonPanel object
65 */
66 public ButtonPanel() {
67 this.setLayout(new GridLayout(1, 0, 4, 4));
68 setFloatable(false);
69 }
70 }
71 }
72