Create a Java GUI application that will capture the commission earned by an estate agent for the

sale of a property. The application must capture all the required input and display the estate
agent commission report.Q.2.1 On the form, create one combo box for the estate agent location. The estate agent
locations include Cape Town, Durban, and Pretoria. You are also required to create
three text fields to capture the estate agent name, property price, and commission
percentage. Also, create a text area to display the estate agent report.
Q.2.2 A menu system is required for the user to interact with. The following menu items are
required:
File
• Exit
Tools
• Process Report.
• Clear
• Save Report
Q.2.3 When the Exit menu item is clicked, close the application.

Here is a Java GUI application that captures the commission earned by an estate agent for the sale of a property, as per the given requirements:

```java
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class EstateAgentCommissionApp extends JFrame {
private JComboBox<String> locationComboBox;
private JTextField agentNameField, propertyPriceField, commissionPercentageField;
private JTextArea reportTextArea;

public EstateAgentCommissionApp() {
setTitle("Estate Agent Commission App");
setSize(400, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// Create menu bar
JMenuBar menuBar = new JMenuBar();

// Create File menu and Exit menu item
JMenu fileMenu = new JMenu("File");
JMenuItem exitMenuItem = new JMenuItem("Exit");
exitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
fileMenu.add(exitMenuItem);
menuBar.add(fileMenu);

// Create Tools menu, Process Report menu item, Clear menu item, and Save Report menu item
JMenu toolsMenu = new JMenu("Tools");
JMenuItem processReportMenuItem = new JMenuItem("Process Report");
processReportMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
processReport();
}
});
toolsMenu.add(processReportMenuItem);

JMenuItem clearMenuItem = new JMenuItem("Clear");
clearMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
clearFields();
}
});
toolsMenu.add(clearMenuItem);

JMenuItem saveReportMenuItem = new JMenuItem("Save Report");
saveReportMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
saveReport();
}
});
toolsMenu.add(saveReportMenuItem);

menuBar.add(toolsMenu);
setJMenuBar(menuBar);

// Create form components
locationComboBox = new JComboBox<String>(new String[]{"Cape Town", "Durban", "Pretoria"});
agentNameField = new JTextField(20);
propertyPriceField = new JTextField(20);
commissionPercentageField = new JTextField(20);
reportTextArea = new JTextArea(10, 30);
reportTextArea.setEditable(false);

// Create form layout
JPanel formPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST;
gbc.insets = new Insets(5, 5, 5, 5);

gbc.gridx = 0;
gbc.gridy = 0;
formPanel.add(new JLabel("Estate Agent Location:"), gbc);

gbc.gridx = 1;
formPanel.add(locationComboBox, gbc);

gbc.gridx = 0;
gbc.gridy = 1;
formPanel.add(new JLabel("Estate Agent Name:"), gbc);

gbc.gridx = 1;
formPanel.add(agentNameField, gbc);

gbc.gridx = 0;
gbc.gridy = 2;
formPanel.add(new JLabel("Property Price:"), gbc);

gbc.gridx = 1;
formPanel.add(propertyPriceField, gbc);

gbc.gridx = 0;
gbc.gridy = 3;
formPanel.add(new JLabel("Commission Percentage:"), gbc);

gbc.gridx = 1;
formPanel.add(commissionPercentageField, gbc);

// Create report layout
JPanel reportPanel = new JPanel(new BorderLayout());
reportPanel.add(new JScrollPane(reportTextArea), BorderLayout.CENTER);

// Add form and report panels to main frame
getContentPane().add(formPanel, BorderLayout.NORTH);
getContentPane().add(reportPanel, BorderLayout.CENTER);

setVisible(true);
}

private void processReport() {
String agentLocation = (String) locationComboBox.getSelectedItem();
String agentName = agentNameField.getText();
double propertyPrice = Double.parseDouble(propertyPriceField.getText());
double commissionPercentage = Double.parseDouble(commissionPercentageField.getText());

double commission = propertyPrice * commissionPercentage / 100;

String report = "Estate Agent Location: " + agentLocation + "\n" +
"Estate Agent Name: " + agentName + "\n" +
"Property Price: " + propertyPrice + "\n" +
"Commission Percentage: " + commissionPercentage + "%\n" +
"Commission Earned: $" + commission;

reportTextArea.setText(report);
}

private void clearFields() {
locationComboBox.setSelectedIndex(0);
agentNameField.setText("");
propertyPriceField.setText("");
commissionPercentageField.setText("");
reportTextArea.setText("");
}

private void saveReport() {
String fileContents = reportTextArea.getText();

JFileChooser fileChooser = new JFileChooser();
int result = fileChooser.showSaveDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
try {
File fileToSave = fileChooser.getSelectedFile();
FileWriter fw = new FileWriter(fileToSave);
fw.write(fileContents);
fw.close();
JOptionPane.showMessageDialog(this, "Report saved successfully!");
} catch (IOException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Error while saving the report.", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new EstateAgentCommissionApp();
}
});
}
}
```

To run this application, you will need to have the Java Swing library installed. You can compile and run the application using any Java compiler or IDE of your choice.