39 lines
833 B
Java
39 lines
833 B
Java
package buttons2;
|
|
import javax.swing.*;
|
|
|
|
/**
|
|
* A frame with a button panel.
|
|
* @version 1.00 2007-11-02
|
|
* @author Cay Horstmann
|
|
*/
|
|
public abstract class ButtonFrame extends JFrame
|
|
{
|
|
public static final int DEFAULT_WIDTH = 300;
|
|
public static final int DEFAULT_HEIGHT = 200;
|
|
|
|
protected JPanel panel;
|
|
protected JButton yellowButton;
|
|
protected JButton blueButton;
|
|
protected JButton redButton;
|
|
|
|
protected abstract void addEventHandlers();
|
|
|
|
public ButtonFrame()
|
|
{
|
|
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
|
|
|
panel = new JPanel();
|
|
add(panel);
|
|
|
|
yellowButton = new JButton("Yellow");
|
|
blueButton = new JButton("Blue");
|
|
redButton = new JButton("Red");
|
|
|
|
panel.add(yellowButton);
|
|
panel.add(blueButton);
|
|
panel.add(redButton);
|
|
|
|
addEventHandlers();
|
|
}
|
|
}
|