Home CPSC 220

GUI Exercise

 

Objective

To become more familiar with GUI programming in Java.
 

Task

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.


 

Details

  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

 

Submitting

When your program works, email the code to ifinlay@umw.edu.

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