Java Reference
In-Depth Information
Listing 12-11. The WeatherWidget MIDlet Modified to Use the WeatherFetcher Class
package com.apress.rischpater.weatherwidget;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;
public class WeatherWidget extends MIDlet implements CommandListener {
private Form wxForm;
private StringItem locationItem;
private StringItem wxItem;
private Command exitCommand;
private Command screenCommand;
private Command settingCommand;
private Command okCommand;
private Command backCommand;
private Command updateCommand;
private List locationList;
private TextBox locationTextBox;
private Alert cannotAddLocationAlert;
private WeatherFetcher fetcher;
private Location location;
private LocationStore locationStore;
private void initialize() {
locationStore = new LocationStore();
String[] locations = locationStore.getLocationStrings();
try {
if (locations.length > 0 )
location = locationStore.getLocation(locations[0]);
}
catch(Exception e){}
fetcher = new WeatherFetcher(location, this);
getDisplay().setCurrent(get_wxForm());
}
public void startApp() {
initialize();
}
public void pauseApp() {
}
 
Search WWH ::




Custom Search