Home CPSC 240

Lab 13: GUI Exercise



To become more familiar with GUI programming in Java.



For this lab, you will create a simple GUI program with Swing. The program will contain a window with three components:

They will need to be contained inside of a BoxLayout.

The label should tell the user to enter a number in the field below.

The text field will allow the user to enter a number.

When the button is pressed, the application should read the text in the text field, convert it to a number, calculate the factorial of the number, and display it in a popup window to the user.



  1. The examples in class detail the use of a BoxLayout, JLabel, JButton and messages.
  2. You will need to read about the JTextField on your own.
  3. You can use Integer.parseInt(string) to convert text into an int.
  4. You can use Integer.toString(number) to convert from an int to a String



When you are done, please submit the Java code under the assignment in Canvas.

Copyright © 2023 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.