ButtonPanel Java

ButtonPanel Java - .setAlignmentY( RIGHT_ALIGNMENT ); this...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/**Meredith Thomas * Section 003 */ import javax.swing.*; import java.awt.*; import java.awt.event.*; public class ButtonPanel extends JPanel /**implements ActionListener*/ { /** * */ public JButton clearButton ; public JButton doneButton ; public JPanel jPanel ; public ButtonPanel() { //jPanel = new JPanel(); super ( new GridLayout(1,2)); //Clear button this . clearButton = new JButton( "Clear" ); this . clearButton .setAlignmentY( LEFT_ALIGNMENT ); this . clearButton .setActionCommand( "clear" ); this . clearButton .setBackground( null ); //this.clearButton.addActionListener(this); super .add( clearButton ); //Done button this . doneButton = new JButton( "Done" ); this . doneButton
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .setAlignmentY( RIGHT_ALIGNMENT ); this . doneButton .setActionCommand( "done" ); this . clearButton .setBackground( null ); //this.doneButton.addActionListener(this); super .add( doneButton ); } public void actionPerformed(ActionEvent pressed) { String buttonPressed = pressed.getActionCommand(); System. out .println( "button listener in button panel working" ); if (buttonPressed.equalsIgnoreCase( "done" )){ System. exit (0); } else if (buttonPressed.equalsIgnoreCase( "clear" )){ Minefield theGame = new Minefield(); } } }...
View Full Document

Ask a homework question - tutors are online