/**
* Creates a control panel to use in the south section of a boarder layout.
*
* @author T. K. Rogers
* @version 1-23-04
*/
import java.awt.* ;
import java.awt.event.* ;
import javax.swing.* ;
import javax.swing.event.* ;
import javax.swing.border.* ;
public class SouthControlPanel extends JPanel implements ActionListener {
// Creates empty panels used for spacing. Note: panels can only be used once.
private JPanel emptyPanel1 = new JPanel ( new GridLayout ( 1, 1 ) ) ,
emptyPanel3 = new JPanel ( new GridLayout ( 1, 1 ) ) ,
emptyPanel4 = new JPanel ( new GridLayout ( 1, 1 ) ) ;private JButton startButton ,
stopButton ,
resetButton ;public SouthControlPanel ( ) {
setLayout ( new GridLayout ( 1, 4 ) ) ;
// Sets up buttons
startButton = new JButton ( "start" ) ;
//Improves button appearance.
startButton.setBorder ( BorderFactory.createRaisedBevelBorder ( ) ); startButton.addActionListener ( this ) ;
stopButton = new JButton ( "stop" ) ;
stopButton.setBorder ( BorderFactory.createRaisedBevelBorder ( ) ) ;
stopButton.addActionListener ( this ) ;
resetButton = new JButton ( "reset" ) ;
resetButton.setBorder ( BorderFactory.createRaisedBevelBorder ( ) ) ;
resetButton.addActionListener ( this ) ;
// Gives the panel a border with a title.
setBorder ( new TitledBorder ( new EtchedBorder ( ) , "South Control Panel" ) ) ;
add ( startButton ) ;
add ( stopButton ) ;
add ( resetButton ) ;
add ( emptyPanel3 ) ; // Empty panels are needed for spacing}
/////////////////////////////////////////////////////////////////////////
public void actionPerformed ( ActionEvent e ) {Object source = e.getSource ( ) ;
if ( source == startButton ) {// Enter your code here.
}
if ( source == stopButton ) {// Enter your code here.
}
if ( source == resetButton ) {// Enter your code here.
}
}
}