Step 2


Overview

In this step you will add a JComboBox to the control panel for selecting the drawing method in the draw panel. At this time, it will not be operable.

You will first write a helper method to construct and configure the control. Then you declare an instance variable for it, using the helper for initialization. Finally, you add a line of code to the createControlPanel() helper to add the control to the control panel.

The createMethodControl() Helper Method

Like the createControlPanel() helper, this helper should omit the public keyword. It constructs and returns a JComboBox. The combo box should have its preferred and maximum sizes set to 160 by 55. It should have a titled border with the title "method". At this time, it should only have one item added: "drawString". This should also be the selected item for the combo box.

And Then Two More Line of Code

Now all you need to do is

That's all there is to this step. When you run your applet, it should look like the following demonstration applet.

Demonstration Applet