Description: This Work graded 100
class SaveSalesListener implements ActionListener {
/**
* Saves the sales informations in a file.
*
* @param event the event object.
*/
public void actionPerformed(ActionEvent event) {
if (sales.getNumberOfOrders() == 0) {
statusTextArea.setText("No order has been sold.")
}
else {
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY)
int result = fileChooser.showSaveDialog(null)
if (result != JFileChooser.APPROVE_OPTION) {
statusTextArea.setText("The sales information has " +
"not been saved.")
}
else {
File file = fileChooser.getSelectedFile()
try {
PrintWriter output = new PrintWriter(
new FileWriter(file))
output.print(salesFormatter.formatSales(sales))
output.close()
}
catch (IOException ioe) {
statusTextArea.setText("Error: Problem with I/O.")
To Search:
File list (Check if you may need any files):
GourmetCoffeeGUI.java