Creating the new methods

The next step in enhancing the To-Do List program is adding some methods that contain the logic for the To-Do List program to read and write To-Do files.

Here are the individual tasks that need to be completed to create the new class:

The following sections describe these tasks in more detail.

Importing classes required by the new methods

The new methods require two classes to be imported: com.sun.java.swing.* and java.io.* To import these additional classes:

  1. From the Workbench, select the ToDoList class.
  2. In the Source pane, add these statements beneath the existing import statements for the java.applet.* and java.awt.* classes:
     import com.sun.java.swing.*;
     import java.io.*;
    

Adding a static variable required by the new methods

The new methods require a static variable to hold the name of the file in which the to-do list will be saved. Add this variable as follows:

  1. From the Workbench, select the ToDoList class.
  2. In the Source pane, add this statement beneath the fields defined for the class:
    static String FILE_NAME = "todo.lst";
    

Save your changes. Click mouse button 2 in the Source pane. Click Save.