0% found this document useful (0 votes)
11 views45 pages

11 OOP Case Studies 19092023 025432pm

The document discusses several Java GUI applications including adding two numbers, operations on two numbers, calculating number of days in a month, and a picture viewer. It describes the GUI components, logic, and features of each application.

Uploaded by

Bilal choudhry
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)
11 views45 pages

11 OOP Case Studies 19092023 025432pm

The document discusses several Java GUI applications including adding two numbers, operations on two numbers, calculating number of days in a month, and a picture viewer. It describes the GUI components, logic, and features of each application.

Uploaded by

Bilal choudhry
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/ 45

Discovering Knowledge

CSC-210
Object-Oriented Programming

Lecturer
Sameena Javaid

https://sites.google.com/site/sameenajavaidcs

© Bahria University Department of Computer Science | Bahria University 1


Discovering Knowledge

OOP CASE STUDIES

© Bahria University Department of Computer Science | Bahria University 2


Discovering Knowledge

Application Adding Two


Numbers

GUI Component: Panel, Label, TextField, Button


Logic Programming: if-else
Events: actionPerformed
Features: requestFocus, System.exit(0)

© Bahria University Department of Computer Science | Bahria University 3


Discovering Knowledge

Applications Added Two Numbers


1. First number and
Second number
entered by the user
2. Clicking the Add
button will come
out the result in the
third field
3. Clear button to clear
the text fields
4. After the Clear
button, point focus
to TextField First
number

© Bahria University Department of Computer Science | Bahria University 4


Discovering Knowledge

Application Operations
on Two Numbers

GUI Component: Panel, Label, TextField, Button


Logic Programming: if-else
Event: actionPerformed, keyTyped
Features: the making of new method

© Bahria University Department of Computer Science | Bahria University 5


Discovering Knowledge

Operation on Two Numbers


Additional Features:
1. Error dialog
appears when the
input value is not
numeric
2. Use Event
keyTyped on
TextField to show
error
3. Bring up the error
dialog:
JOptionPane.show
MessageDialog
(this, "error");
© Bahria University Department of Computer Science | Bahria University 6
Discovering Knowledge

The new method

© Bahria University calling method


Department of Computer Science | Bahria University 7
Discovering Knowledge

class and a new method

© Bahria University Department of Computer Science | Bahria University 8


Discovering Knowledge

Application to Calculate
Number of Days

GUI Component: Panel, Label, TextField,


PasswordField,
Button, ComboBox
Logic Programming: if-else, switch
Event: actionPerformed, keyTyped

© Bahria University Department of Computer Science | Bahria University 9


Discovering Knowledge

Application to Calculate Number of Days


1. Appears login form, when the
User ID and Password = admin,
then the application will appear
2. Calculate button is clicked, it
will display the number of days
in the month and year
designated
3. Note that there is a leap year
calculations in February
4. Save button to save the results
to a file
Error Dialog:
1. Error dialog appears when the
input value is not numeric
(digits)
2. Error dialog appears when the
field is empty

© Bahria University Department of Computer Science | Bahria University 10


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 11


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 12


Discovering Knowledge

Change TextField into ComboBox

© Bahria University Department of Computer Science | Bahria University 13


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 14


Discovering Knowledge

Picture Viewer
application with Button

GUI Component: BorderLayout, Button,


CardLayout
Logic Programming: none
Event: actionPerformed

© Bahria University Department of Computer Science | Bahria University 15


Discovering Knowledge

Picture Viewer (Button)

© Bahria University Department of Computer Science | Bahria University 16


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 17


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 18


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 19


Discovering Knowledge

Picture Viewer application


with Button
(Fullscreen undecorated)

GUI Component: BorderLayout, Button,


CardLayout
Logic Programming: none
Event: actionPerformed

© Bahria University Department of Computer Science | Bahria University 20


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 21


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 22


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 23


Discovering Knowledge

Picture Viewer application


with ComboBox

GUI Component:ComboBox, CardLayout


Logic Programming: none
Event: itemStateChanged

© Bahria University Department of Computer Science | Bahria University 24


Discovering Knowledge

Picture Viewer (ComboBox)

© Bahria University Department of Computer Science | Bahria University 25


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 26


Discovering Knowledge

Login Form and Confirm


Exit Application

GUI Component:TextField, PasswordField,


Menu Bar, Menu Item
Logic Programming: If-Else
Event: KeyPressed

© Bahria University Department of Computer Science | Bahria University 27


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 28


Discovering Knowledge

Student Grade Application

GUI Component: Label, TextField, Button


Logic Programming: if-else, switch
Event: actionPerformed, keyTyped

© Bahria University Department of Computer Science | Bahria University 29


Discovering Knowledge

Student Grade Application


Average Value:
(OOP+MATH+STAT)/3
Grade:
1. 90-: A
2. 80-89: B
3. 70-79: C
Result:
1. A-C: Pass
2. D: Not Passed

Additional Features:
1. Error dialog appears when the
input value is not numeric, the
value is between 0-100, or blank
entries
2. Confirm when exiting the
application

© Bahria University Department of Computer Science | Bahria University 30


Discovering Knowledge

© Bahria University Department of Computer Science | Bahria University 31


Discovering Knowledge

Calculator
Application
GUI Component: Panel,
TextArea, Button
Logic Programming: If-Else,
Switch

© Bahria University Department of Computer Science | Bahria University 32


Discovering Knowledge

Calculator Application
1. How to work like a
calculator
2. We press the button
which will appear on
the screen
3. The result of the
calculation will
appear on the screen
4. Description:
C = clear screen
B = backspace
E = exit
5. Exit to confirmation

© Bahria University Department of Computer Science | Bahria University 33


Discovering Knowledge

Hints: How calculator works?


7 + 8 = 15
operandFirst operator operandSecond equal result

1. operandFirst: show number pressed on the screen


2. operator:
1. Take on the screen, save it as a variable operandFirst
2. Tick ​what the operator is executed (+, -, *, etc.)
3. operandSecond: show number pressed on the screen
4. equal to:
1. Take on the screen, save it as a variable operandSecond
2. Make a decision (if or switch), the what operator is used and what process do
if (operator.equals ("+")) {
layar.setText (operandFirst + operandSecond);
} else if () {...
}

© Bahria University Department of Computer Science | Bahria University 34


Discovering Knowledge

Text to Speech
Application
GUI Component: CheckBox,
ComboBox, RadioButton,
TextArea
Logic Programming: If-Else

© Bahria University Department of Computer Science | Bahria University 35


Discovering Knowledge

Text to Speech Application


1. Enter the text in the
form of a sentence into
a TextArea
2. When the Speak Text
button, the text has
been written will
dibuah into bentu voice
(can read)
3. Hints:
Use library FreeTTS
from
http://sourceforge.net/
projects/freetts/

© Bahria University Department of Computer Science | Bahria University 36


Discovering Knowledge


Text to Speech
Searching on Google with
Application
the keyword "Free TTS jar”
• Download freetts.jar library
and insert into the libraries
directory -> right click add
jar / folder
• Create user interface
design, and create an event
on the Speak Text button
that contains the code for a
sound logic of the text
(only need 4 lines of code)

© Bahria University Department of Computer Science | Bahria University 37


Discovering Knowledge

Biodata Organization
Application
GUI Component: CheckBox,
ComboBox, RadioButton,
TextArea
Logic Programming: If-Else

© Bahria University Department of Computer Science | Bahria University 38


Discovering Knowledge

Biodata Organization Application


1. Name and Address
written
2. Jobs (civil servants,
military, Employees,
Employers)
3. Selected Gender been
4. Bold print in check
5. When click View, then
the data will be
displayed in the
TextArea below
6. The Save button to
save the file (txt)
© Bahria University Department of Computer Science | Bahria University 39
Discovering Knowledge

Hints
Font large = new Font(“Arial”, Font.BOLD, 12)
Font small = new Font(“Arial”, Font.PLAIN, 12)

if(yesLarge.getText().equals(“Yes”)){
resultTextArea.setFont(large);
} else {
resultTextArea.setFont(small);
}

© Bahria University Department of Computer Science | Bahria University 40


Discovering Knowledge

Student Biodata
Application
GUI Component: Menubar,
Menuitem, Table

© Bahria University Department of Computer Science | Bahria University 41


Discovering Knowledge

Student Biodata1.Application
Applications with full
frame along with the
menubar and menuitem
2. Data filled then clicked
Add, the data will be
entered into the table
3. Clean: cleaning the
stuffing in TextField
4. Delete: delete records in
table
5. Save: save the records in
the file
6. Exit: exit the application

© Bahria University Department of Computer Science | Bahria University 42


Discovering Knowledge

ATM System
• Develop applications Banks that
we've got up, become
distinguished based ATM system
to a GUI
• Use Bank.java class as a class that
helps control balance process
look, take the money and save
money
• Use the displacement frame for
MenuLogin and MenuUtama
• Use dialog
(JOptionPane.showInputDialog)
to retrieve data on Saving Money
and Take the Money

© Bahria University Department of Computer Science | Bahria University 43


Discovering Knowledge

Conversion Currency Exchange

© Bahria University Department of Computer Science | Bahria University 44


Discovering Knowledge

Currency Exchange Rate Conversion


Complete
1 USD = 108 .00RP 1 EUR = 127.73 RP 1 JPY = 99 RP

© Bahria University Department of Computer Science | Bahria University 45

You might also like