CSC 120 Lab 10
In this lab we will practice using methods of the String class, as well as JLabels, JButtons,
JTextFields and JTextAreas.
- If you didn't do so before today's class, watch
this video
that introduces the
String
class and some of the methods that may be used
to process String data (approx. 9 minutes in length).
- Get the beginning version of the program up and running.
- Create a new Netbeans project called Lab10.
Make sure the Location is in your CSC120\Java folder.
- In your web browser, right click on
MUFrame.java
and choose Save Target As... (or Save Link As...)
and save the files in the src folder of your project.
- Compile and run the program to see how the interface looks. Then
type some text in the
input field and click the button to see the output. Then edit the
value you typed in the input field, and click the button again.
Notice that the output JTextArea displays the results of
our processing, which is only one operation at this time.
- Add more code to the program to produce more kinds of output.
- Click HERE
to see a sample finished version of this lab.
- When a user types something in the input field, then clicks the button,
the program should produce all of the output shown in the example.
- Complete each of the other kinds of output ONE AT A TIME.
Finish getting one working before you start working on the next one.
For each of the other kinds of output shown in the sample output:
- Add a method in the MUFrame class that will display output
in the JTextArea. Use the
capitalizeInputText
method
as a pattern for your new methods.
Try to figure out by yourself which method(s) from the String class
you'll need to use to produce a new String for the desired output.
If you get stuck, ask for help but only after looking at the
String class methods.
Hint: you may find it helpful to focus on these specific methods and operators of the String class
when working on code to generate the sample output produced in this lab assignment:
Operators:
+
Methods:
toUpperCase
toLowerCase
charAt
substring
length
indexOf
- Add a line of code in the
processInputButtonActionPerformed
method of the MUFrame class to call the new method.
- Run your program and fix any problems.
Only add one new kind of output, then
test & fix, then add another, then test & fix, etc.
- Submit your Lab10 project as a .zip file to the
D2L dropbox for grading, as usual.