<<< A6 Making a Reusable ApplicationFrame Class, cont. | Index | Using the Color class >>> |
Our next sample demonstrates a simple program with two buttons in a frame.
Change Color button changes the color of the background.
Quit button causes the program to exit.
Swing demo A7 creates GUI window with two buttons:
FrameApplication.java (download) extends javax.swing.JFrame
FrameTwoButtons.java (download) extends FrameApplication and implements ActionListener
Notice few more changes that took place in FrameApplication class:
Although setFrameDimension( ) remains, it is no longer invoked by the constructor, presuming that the derived class will do that.
The
JFrame.setVisible(true);
is now a responsibility of the FrameTwoButtons constructor.
<<< A6 Making a Reusable ApplicationFrame Class, cont. | Index | Using the Color class >>> |