Changes to the AddressBook GUI
The new AddressBook differs from the old one in that it now presents a menu to the user, allowing the user to select from two options:
-
LoadXML
-
LoadDB
This menu option is implemented through the creation of two Command objects using the Command.SCREEN type:
static final Command cmdXML = new Command("LoadXML", Command.SCREEN, 1);
static final Command cmdDB = new Command("LoadDB", Command.SCREEN, 1);
If either of these items is selected, the loadAddressDB(boolean fromXML) method is called. This method first clears the mnuMain menu and either loads addresses from a remote XML file or from the local database:
public void loadAddressDB(boolean fromXML) { //First, clear the list while (mnuMain.size() > 0) { mnuMain.delete(0); } if (fromXML) { dbAddress.loadXML(); } int count = dbAddress.recordCount(); for (int i=0; i < count; i++) { mnuMain.append(dbAddress.getName(i+1), null); } }