001: /* ========================================================================
002: * JCommon : a free general purpose class library for the Java(tm) platform
003: * ========================================================================
004: *
005: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jcommon/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * --------------------
028: * L1R2ButtonPanel.java
029: * --------------------
030: * (C) Copyright 2000-2004, by Object Refinery Limited.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: L1R2ButtonPanel.java,v 1.3 2005/10/18 13:18:34 mungady Exp $
036: *
037: * Changes (from 26-Oct-2001)
038: * --------------------------
039: * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;
040: * 26-Jun-2002 : Removed unnecessary import (DG);
041: * 14-Oct-2002 : Fixed errors reported by Checkstyle (DG);
042: *
043: */
044:
045: package org.jfree.ui;
046:
047: import java.awt.BorderLayout;
048: import java.awt.GridLayout;
049:
050: import javax.swing.JButton;
051: import javax.swing.JPanel;
052:
053: /**
054: * A 'ready-made' panel that has one button on the left and two buttons on the right - nested
055: * panels and layout managers take care of resizing.
056: *
057: * @author David Gilbert
058: */
059: public class L1R2ButtonPanel extends JPanel {
060:
061: /** The left button. */
062: private JButton left;
063:
064: /** The first button on the right of the panel. */
065: private JButton right1;
066:
067: /** The second button on the right of the panel. */
068: private JButton right2;
069:
070: /**
071: * Standard constructor - creates a three button panel with the specified button labels.
072: *
073: * @param label1 the label for button 1.
074: * @param label2 the label for button 2.
075: * @param label3 the label for button 3.
076: */
077: public L1R2ButtonPanel(final String label1, final String label2,
078: final String label3) {
079:
080: setLayout(new BorderLayout());
081:
082: // create the pieces...
083: this .left = new JButton(label1);
084:
085: final JPanel rightButtonPanel = new JPanel(new GridLayout(1, 2));
086: this .right1 = new JButton(label2);
087: this .right2 = new JButton(label3);
088: rightButtonPanel.add(this .right1);
089: rightButtonPanel.add(this .right2);
090:
091: // ...and put them together
092: add(this .left, BorderLayout.WEST);
093: add(rightButtonPanel, BorderLayout.EAST);
094:
095: }
096:
097: /**
098: * Returns a reference to button 1, allowing the caller to set labels, action-listeners etc.
099: *
100: * @return the left button.
101: */
102: public JButton getLeftButton() {
103: return this .left;
104: }
105:
106: /**
107: * Returns a reference to button 2, allowing the caller to set labels, action-listeners etc.
108: *
109: * @return the right button 1.
110: */
111: public JButton getRightButton1() {
112: return this .right1;
113: }
114:
115: /**
116: * Returns a reference to button 3, allowing the caller to set labels, action-listeners etc.
117: *
118: * @return the right button 2.
119: */
120: public JButton getRightButton2() {
121: return this.right2;
122: }
123:
124: }
|