have a GUI class that has 2 text fields and a submit and reset button.
I have added all the listeners and would like to process this form if auser clicks on the submit button.However, if he clicks on the reset button, I want the form to clear.
What should I do so that when I click the submit button, I get the values of the two text fields and when I click the reset button, the form just resets.
Below are snippets of code for the rest of my Gui.
class NameL implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
nameE = nameInput.getText();
}
}
class LocationL implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
locChoices = (JComboBox)e.getSource();
locationE = (
String)locChoices.getSelectedItem();
}
}
class ButtonL implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String name = ((JButton)e.getSource()).getText();
if(name.equals("submit"))
System.out.println("create a vector with all the values you have got " + nameE + " and" + locationE);
else
System.out.println("you have pressed the reset button and must clear all the fields");
}
}