Frames | No Frames |
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.4 2007/11/02 17:50:36 taqua 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; 48: import java.awt.GridLayout; 49: import javax.swing.JButton; 50: import javax.swing.JPanel; 51: 52: /** 53: * A 'ready-made' panel that has one button on the left and two buttons on the right - nested 54: * panels and layout managers take care of resizing. 55: * 56: * @author David Gilbert 57: */ 58: public class L1R2ButtonPanel extends JPanel { 59: 60: /** The left button. */ 61: private JButton left; 62: 63: /** The first button on the right of the panel. */ 64: private JButton right1; 65: 66: /** The second button on the right of the panel. */ 67: private JButton right2; 68: 69: /** 70: * Standard constructor - creates a three button panel with the specified button labels. 71: * 72: * @param label1 the label for button 1. 73: * @param label2 the label for button 2. 74: * @param label3 the label for button 3. 75: */ 76: public L1R2ButtonPanel(final String label1, final String label2, final String label3) { 77: 78: setLayout(new BorderLayout()); 79: 80: // create the pieces... 81: this.left = new JButton(label1); 82: 83: final JPanel rightButtonPanel = new JPanel(new GridLayout(1, 2)); 84: this.right1 = new JButton(label2); 85: this.right2 = new JButton(label3); 86: rightButtonPanel.add(this.right1); 87: rightButtonPanel.add(this.right2); 88: 89: // ...and put them together 90: add(this.left, BorderLayout.WEST); 91: add(rightButtonPanel, BorderLayout.EAST); 92: 93: } 94: 95: /** 96: * Returns a reference to button 1, allowing the caller to set labels, action-listeners etc. 97: * 98: * @return the left button. 99: */ 100: public JButton getLeftButton() { 101: return this.left; 102: } 103: 104: /** 105: * Returns a reference to button 2, allowing the caller to set labels, action-listeners etc. 106: * 107: * @return the right button 1. 108: */ 109: public JButton getRightButton1() { 110: return this.right1; 111: } 112: 113: /** 114: * Returns a reference to button 3, allowing the caller to set labels, action-listeners etc. 115: * 116: * @return the right button 2. 117: */ 118: public JButton getRightButton2() { 119: return this.right2; 120: } 121: 122: }