The Poona Gujrati Kelvani Mandal’s
Haribhai V. Desai College of Arts, Science and Commerce, Pune
DEPARTMENT OF COMPUTER SCIENCE
Academic Year: 2024-25
Class – T.Y.B.Sc (Comp. Sci.) Div -A and B
Subject- CS-355 Object oriented programming in Java-I
PRACTICAL ASSIGNMENT5
CHAPTER5- GUI Designing and Event Handling.
1. Write a program to design a screen using Awt that will take a user name and
password. If the user name and password are not same, raise an Exception with
appropriate message.User can have 3 login chances only. Use clear button to clear
the TextFields.
2. Design a screen to handle the Mouse Events such as MOUSE_MOVED and
MOUSE_CLICKED and display the position of the Mouse_Click in a TextField.
3. Write a java program that works as a simple calculator. Use a grid layout to
arrange buttons forthe digits and for the +, -, *, % operations. Add a text field to
display the result.
4.
5. Write Java program to design three text boxes and two buttons using swing. Enter
different strings in first and second textbox. On clicking the First command button,
concatenation of two strings should be displayed in third text box and on clicking
second command button, reverse of string should display in third text box
6. Write a program to implement Border Layout Manager.
7. Write a program which shows the combo box which includes list of
T.Y.B.Sc.(Comp. Sci) subjects. Display the selected subject in a text field
8. Write a program that handles all mouse events and shows the event name at the
center of the Window, red in color when a mouse event is fired. (Use adapter
classes).
9. Write a simple currency converter, as shown in the figure. User can enter
the amount of "Singapore Dollars", "US Dollars", or "Euros", in floating-
point number. The convertedvalues shall be displayed to 2 decimal places.
Assume that 1 USD = 1.41 SGD, 1 USD = 0.92 Euro, 1 SGD = 0.65 Euro
10. Create the following GUI screen using appropriate layout manager. Accept
the name, class,hobbies from the user and display the selected options in a
textbox.
11. Write a program called SwingTemperatureConverter to convert temperature
values between Celsius and Fahrenheit. User can enter either the Celsius or the
Fahrenheit value, in floating-point number. Hints: To display a floating-point
number in a specific format (e.g., 1 decimal place), use the static method
String.format(), which has the same form as printf(). For example,
String.format("%.1f", 1.234) returns String "1.2".
12. Write a program to create a class
Customer(custno,custname,contactnumber,custaddr). Write a method to search
the customer name with given contact number and display the details.
13. Write a program that creates a user interface to perform integer
divisions. The user enters two numbers in the text fields, Number1 and
Number2. The division of Number1 and Number2 is displayed in the
Result field when the Divide button is clicked. If Number1 or Number2
were not an integer, the program would throw a
NumberFormatException. If Number2 were Zero, the program would
throw an Arithmetic Exception Display the exception in a message dialog
box.