Background
Lines 1-3 shoudl have comments that include your name and the date.
Lines 4-6 import requried libraries
Lines 9-10: These 2 declarations create private fields because the fields need to be accessed later in the listener.
Line 13: FlowLayout is the simplest GUI layout. The first component added to the panel is placed at the center top. Additional components are placed to the right, or on the next line. Be sure to drag the corner of the frame and watch how the flow works.
Line 15-31. Notice the different components are instantiated, formatted, and added to the panel. Components appear in the order in which they are added.
Line 19: This button is declared local because it does not need to be accessed in the listener, unlike the label and the textfield.
Specification
Filename Driver01.java. Create an appropriate driver. Make sure to add a panel object of type Panel01.
Filename Panel01.java. Implement the method actionPerformed() to find square roots.
What happens if you type a negative number into the text box?
Extension
Edit your program to handle negative numbers correctly, i.e., returns 5i. You will need an if-statement.
Warning! A common error is to write Line 15 as JTextField box = new JTextField("0.0", 10); Write Line 15 with this mistake. Compile and run. Explain the error message.