Chapter 15
606
// System.out.println("Current filter is now " + currentRegionFilter);
if (listNeedUpdate) {
updateListData();
listNeedUpdate = false;
}
filterList();
}
}
actionPerformed() is called whenever the Update button is clicked. We then make a call to the
remote server, and reset the filter list:
public void actionPerformed(ActionEvent evt) {
updateListData();
filterList();
listNeedUpdate = false;
}
}
We will need to create the next class in order to compile the applet, so we will leave that for the
moment. The file should be saved in the vacserv\ directory.
Parsing and Converting XML Data: The DealsParser Class
The DealsParser class parses an XML document containing a list of sell-offs and creates a vector of
TravelDeal instances. Below is TravelDeals.java, which you can find it in the vacserv\
directory. As you can see, it is a straightforward class containing easily accessible ID, commission,
region, and description information.
public class TravelDeal {
public static final int HAWAII = 1;
public static final int MEXICO = 2;
public static final int CARIBBEAN = 3;
private int Region;
private int Commission;
private int ID;
private String Description;
public TravelDeal(int inID, int inRegion, int inCommission,
String inDesc) {
ID = inID;
Region = inRegion;
Commission = inCommission;
Description = inDesc;
}
public void setRegion(int inRegion) {
Region = inRegion;
}
public int getRegion() {
return Region;
}