What is recursion?
Solving a problem recursively involves solving a simplified version of that same problem Let's look at some examples.
Compute the area of a triangle of width n Assume each [ ] square has an area o
Use JTextArea for multiple lines of text Can specify number of rows and columns:
final int ROWS = 10; final int COLUMNS = 30; JTextArea textArea = new JTextArea(ROWS, COLUMNS);
setText: to set the text of a text field or t
A frame contains a menu bar The menu bar contains menus A menu contains submenus and menu items
Menu bars contain menus
JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar);
Figure 7: Pull-Down Menus
Reading Text Files
Simplest way to read text: use Scanner class To read from a disk file, construct a FileReader Then, use the FileReader to construct a Scanner object
FileReader reader = new FileReader("input.txt"); Scanner in = new Scanner(reade
Traditional approach: Method returns error code Problem: Forget to check for error code
Failure notification may go undetected
Problem: Calling method may not be able to do anything about failure