The answer is (I hope) obvious. It is a good idea to keep the GUI code and the application code in separate modules to help in debugging and understanding the program. This is also helpful if you later need to make changes to the program, say changing it from an application to an applet. The application code can be carried over without change.
Let us develop another GUI application. The USDA recommends that the food you eat have less than 30% of its total calories in fat. This application calculates the percentage of calories that come from fat, given the number of grams of fat and the number of calories per serving of a food. Fat contains 9 calories per gram.