KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfree > ui > L1R2ButtonPanel


1 /* ========================================================================
2  * JCommon : a free general purpose class library for the Java(tm) platform
3  * ========================================================================
4  *
5  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
6  *
7  * Project Info: http://www.jfree.org/jcommon/index.html
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * --------------------
28  * L1R2ButtonPanel.java
29  * --------------------
30  * (C) Copyright 2000-2004, by Object Refinery Limited.
31  *
32  * Original Author: David Gilbert (for Object Refinery Limited);
33  * Contributor(s): -;
34  *
35  * $Id: L1R2ButtonPanel.java,v 1.3 2005/10/18 13:18:34 mungady Exp $
36  *
37  * Changes (from 26-Oct-2001)
38  * --------------------------
39  * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;
40  * 26-Jun-2002 : Removed unnecessary import (DG);
41  * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);
42  *
43  */

44
45 package org.jfree.ui;
46
47 import java.awt.BorderLayout JavaDoc;
48 import java.awt.GridLayout JavaDoc;
49
50 import javax.swing.JButton JavaDoc;
51 import javax.swing.JPanel JavaDoc;
52
53 /**
54  * A 'ready-made' panel that has one button on the left and two buttons on the right - nested
55  * panels and layout managers take care of resizing.
56  *
57  * @author David Gilbert
58  */

59 public class L1R2ButtonPanel extends JPanel JavaDoc {
60
61     /** The left button. */
62     private JButton JavaDoc left;
63
64     /** The first button on the right of the panel. */
65     private JButton JavaDoc right1;
66
67     /** The second button on the right of the panel. */
68     private JButton JavaDoc right2;
69
70     /**
71      * Standard constructor - creates a three button panel with the specified button labels.
72      *
73      * @param label1 the label for button 1.
74      * @param label2 the label for button 2.
75      * @param label3 the label for button 3.
76      */

77     public L1R2ButtonPanel(final String JavaDoc label1, final String JavaDoc label2, final String JavaDoc label3) {
78
79         setLayout(new BorderLayout JavaDoc());
80
81         // create the pieces...
82
this.left = new JButton JavaDoc(label1);
83
84         final JPanel JavaDoc rightButtonPanel = new JPanel JavaDoc(new GridLayout JavaDoc(1, 2));
85         this.right1 = new JButton JavaDoc(label2);
86         this.right2 = new JButton JavaDoc(label3);
87         rightButtonPanel.add(this.right1);
88         rightButtonPanel.add(this.right2);
89
90         // ...and put them together
91
add(this.left, BorderLayout.WEST);
92         add(rightButtonPanel, BorderLayout.EAST);
93
94     }
95
96     /**
97      * Returns a reference to button 1, allowing the caller to set labels, action-listeners etc.
98      *
99      * @return the left button.
100      */

101     public JButton JavaDoc getLeftButton() {
102         return this.left;
103     }
104
105     /**
106      * Returns a reference to button 2, allowing the caller to set labels, action-listeners etc.
107      *
108      * @return the right button 1.
109      */

110     public JButton JavaDoc getRightButton1() {
111         return this.right1;
112     }
113
114     /**
115      * Returns a reference to button 3, allowing the caller to set labels, action-listeners etc.
116      *
117      * @return the right button 2.
118      */

119     public JButton JavaDoc getRightButton2() {
120         return this.right2;
121     }
122
123 }
124
Popular Tags