- /**
- * 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 NewGuiGraphicsDemo demo = new NewGuiGraphicsDemo ( ) ;
- private JButton
startButton ,
-
stopButton ,
-
resetButton ;
- public SouthControlPanel ( ) {
- setLayout(new
GridLayout ( 1, 4 ) ) ;
-
-
// Sets up buttons
- startButton =
new JButton ( "start" ) ;
-
startButton.setBorder ( BorderFactory.createRaisedBevelBorder ( ) ) ;
-
// ^ Improves button appearance ^
-
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) ;
//Empty panels are needed for spacing
- add (resetButton) ;
-
add emptyPanel3) ;
- }
-
/////////////////////////////////////////////////////////////////////////
- public void actionPerformed(ActionEvent
e) {
- Object source =
e.getSource();
- if (source ==
startButton) {
-
GraphicsDisplay.startDot();
- }
-
- if (source ==
stopButton) {
-
GraphicsDisplay.stopDot();
- }
- if(source ==
resetButton)
- {
-
GraphicsDisplay.resetDot();
- }
- }
- }