/Users/lyon/j4p/src/bookExamples/ch26Graphics/carl/logPolar/CommandButton.java
|
1 package bookExamples.ch26Graphics.carl.logPolar;
2
3 //package runJgui;
4
5
6 public abstract class CommandButton extends javax.swing.JButton
7 implements java.awt.event.ActionListener, Runnable {
8 public CommandButton(String s) {
9 super(s);
10 addActionListener(this);
11 }
12
13 public void actionPerformed(java.awt.event.ActionEvent e) {
14 run();
15 }
16
17 // main for testing and demo purposes only
18 public static void main(String args[]) {
19 System.out.println("Testing graphics.carl.CommandButton via main");
20 java.awt.Frame f = new java.awt.Frame();
21 f.setLayout(new java.awt.GridLayout(1, 0));
22 f.add(new CommandButton("Testing command button") {
23 public void run() {
24 System.out.println("gui.run in cb");
25 setBackground(java.awt.Color.green);
26 }
27
28 }
29 );
30 f.setSize(200, 200);
31 f.setBackground(java.awt.Color.red);
32 f.show();
33 }
34 }
35