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: * L1R3ButtonPanel.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: L1R3ButtonPanel.java,v 1.4 2005/11/16 15:58:41 taqua Exp $
036: *
037: * Changes (from 26-Oct-2001)
038: * --------------------------
039: * 26-Oct-2001 : Changed package to com.jrefinery.ui.* (DG);
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:
049: import javax.swing.JButton;
050: import javax.swing.JPanel;
051:
052: /**
053: * A 'ready-made' panel that has one button on the left and three buttons on the right - nested
054: * panels and layout managers take care of resizing.
055: *
056: * @author David Gilbert
057: */
058: public class L1R3ButtonPanel extends JPanel {
059:
060: /** The left button. */
061: private JButton left;
062:
063: /** The first button on the right of the panel. */
064: private JButton right1;
065:
066: /** The second button on the right of the panel. */
067: private JButton right2;
068:
069: /** The third button on the right of the panel. */
070: private JButton right3;
071:
072: /**
073: * Standard constructor - creates panel with the specified button labels.
074: *
075: * @param label1 the label for button 1.
076: * @param label2 the label for button 2.
077: * @param label3 the label for button 3.
078: * @param label4 the label for button 4.
079: */
080: public L1R3ButtonPanel(final String label1, final String label2,
081: final String label3, final String label4) {
082:
083: setLayout(new BorderLayout());
084:
085: // create the pieces...
086: final JPanel panel = new JPanel(new BorderLayout());
087: final JPanel panel2 = new JPanel(new BorderLayout());
088: this .left = new JButton(label1);
089: this .right1 = new JButton(label2);
090: this .right2 = new JButton(label3);
091: this .right3 = new JButton(label4);
092:
093: // ...and put them together
094: panel.add(this .left, BorderLayout.WEST);
095: panel2.add(this .right1, BorderLayout.EAST);
096: panel.add(panel2, BorderLayout.CENTER);
097: panel.add(this .right2, BorderLayout.EAST);
098: add(panel, BorderLayout.CENTER);
099: add(this .right3, BorderLayout.EAST);
100:
101: }
102:
103: /**
104: * Returns a reference to button 1, allowing the caller to set labels, action-listeners etc.
105: *
106: * @return the left button.
107: */
108: public JButton getLeftButton() {
109: return this .left;
110: }
111:
112: /**
113: * Returns a reference to button 2, allowing the caller to set labels, action-listeners etc.
114: *
115: * @return the right button 1.
116: */
117: public JButton getRightButton1() {
118: return this .right1;
119: }
120:
121: /**
122: * Returns a reference to button 3, allowing the caller to set labels, action-listeners etc.
123: *
124: * @return the right button 2.
125: */
126: public JButton getRightButton2() {
127: return this .right2;
128: }
129:
130: /**
131: * Returns a reference to button 4, allowing the caller to set labels, action-listeners etc.
132: *
133: * @return the right button 3.
134: */
135: public JButton getRightButton3() {
136: return this.right3;
137: }
138:
139: }
|