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 right - nested 052 * 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 060 /** The first button on the right of the panel. */ 061 private JButton right1; 062 063 /** The second button on the right of the panel. */ 064 private JButton right2; 065 066 /** 067 * Standard constructor - creates a three button panel with the specified button labels. 068 * 069 * @param label1 the label for button 1. 070 * @param label2 the label for button 2. 071 * @param label3 the label for button 3. 072 */ 073 public L1R2ButtonPanel(final String label1, final String label2, final String label3) { 074 075 setLayout(new BorderLayout()); 076 077 // create the pieces... 078 //this.left = new JButton(label1); 079 080 final JPanel rightButtonPanel = new JPanel(new GridLayout(1, 2)); 081 this.right1 = new JButton(label2); 082 this.right2 = new JButton(label3); 083 rightButtonPanel.add(this.right1); 084 rightButtonPanel.add(this.right2); 085 086 // ...and put them together 087 //add(this.left, BorderLayout.WEST); 088 add(rightButtonPanel, BorderLayout.EAST); 089 090 } 091 092 /** 093 * Returns a reference to button 2, allowing the caller to set labels, action-listeners etc. 094 * 095 * @return the right button 1. 096 */ 097 public JButton getRightButton1() { 098 return this.right1; 099 } 100 101 /** 102 * Returns a reference to button 3, allowing the caller to set labels, action-listeners etc. 103 * 104 * @return the right button 2. 105 */ 106 public JButton getRightButton2() { 107 return this.right2; 108 } 109 110 }