0% found this document useful (0 votes)
2 views2 pages

Java GUI Lab

The document outlines a Java GUI lab exercise for CS202 Spring 2025, requiring the creation of a Java Swing application with two main windows: a Login Screen and a Welcome Screen. The Login Screen includes fields for username and password, along with Login and Exit buttons, while the Welcome Screen displays a welcome message and a Logout button. Functionality includes validation for non-empty fields on login and navigation between screens based on user actions.

Uploaded by

anischelly95
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Java GUI Lab

The document outlines a Java GUI lab exercise for CS202 Spring 2025, requiring the creation of a Java Swing application with two main windows: a Login Screen and a Welcome Screen. The Login Screen includes fields for username and password, along with Login and Exit buttons, while the Welcome Screen displays a welcome message and a Logout button. Functionality includes validation for non-empty fields on login and navigation between screens based on user actions.

Uploaded by

anischelly95
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS202 Spring2025

Java GUI Lab


Objective

The goal of this exercise is to create a Java Swing application with two GUI screens.

Your application should have two main windows (JFrame):

• Screen 1: Login Screen


• Screen 2: Welcome Screen

Screen 1: Login Screen:

Create a JFrame with the title "Login Screen".

The window should contain the following components:

• A JLabel with the text "Username:".


• A JTextField for the user to enter their username.
• A JLabel with the text "Password:".
• A JPasswordField for the user to enter their password.
• A JButton labeled "Login".
• A JButton labeled "Exit".

Screen 2: Welcome Screen:

Create another JFrame with the title "Welcome Screen".

The window should contain the following components:

• A JLabel that displays a welcome message, e.g., "Welcome, [Username]!".


• A JButton labeled "Logout" to return to the Login Screen.

Functionality:

Login Screen:
CS202 Spring2025
• When the "Login" button is clicked, check if the username and password are both
non-empty.
• If valid, hide the Login Screen and display the Welcome Screen with a greeting
message.
• If either field is empty, display an error message using a JOptionPane.
• The "Exit" button should close the application.

Welcome Screen:

• The "Logout" button should hide the Welcome Screen and redisplay the Login
Screen.

You might also like