... 45              JOptionPane.showMessageDialog(ButtonFrame.this, String.format(
46                 "You pressed: %s", event.getActionCommand()));
47           }
48        }
49   }

Fig. 26.16 Testing ButtonFrame.

 1   // Fig. 26.16: ButtonTest.java
 2   // Testing ButtonFrame.
 3   import javax.swing.JFrame;
 4
 5   public class ButtonTest
 6   {
 7      public static void main(String[] args)
 8      {
 9         ButtonFrame buttonFrame = new ButtonFrame();
10         buttonFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
11         buttonFrame.setSize(275, 110);
12         buttonFrame.setVisible(true);
13      }
14   }

Computer code corresponding output.

Lines 14–15 declare JButton variables plainJButton and fancyJButton. The corresponding objects are instantiated ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.