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