I am a beginner. I am building java application which is like a form. First the user fill the whole form and the click OK.
I want to do that as the user clicks OK all the items entered in the JTextField will save in the variables that I declared.

I have do this by ActionListener. I have to press enter every time when I entered anything in JTextField. Like this:

Name=String.format("Set_Id: %s", event.getActionCommand());
Surname=String.format("Set_Id: %s", event.getActionCommand());
DOB=String.format("Set_Id: %s", event.getActionCommand());

Please help how can I do this by using MouseListener. All the values move to variables just by clicking OK.