/* * $Id: ButtonTest.java,v 1.1 1997/12/31 19:38:41 begolej Exp $ * * Copyright (c) 1998 James Begole, All Rights Reserved. * * Permission to use, copy, modify, and distribute this software * and its documentation for NON-COMMERCIAL purposes and without * fee is hereby granted provided that this copyright notice * appears in all copies. Please refer to the file "copyright.html" * for further important copyright and licensing information. * * James Begole MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. James Begole * SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ import com.sun.java.swing.*; import java.awt.event.*; import java.awt.FlowLayout; public class ButtonTest extends JPanel { JButton buttonA = null; JButton buttonB = null; public ButtonTest() { setLayout(new FlowLayout()); buttonA = (JButton)add(new JButton("Button A")); buttonA.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { buttonB.setEnabled(!buttonB.isEnabled()); } }); buttonB = (JButton)add(new JButton("Button B")); buttonB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { buttonA.setEnabled(!buttonA.isEnabled()); } }); } }