Want to build your own Java Calculator in NetBeans? 💻
In this step-by-step Java Swing tutorial, you’ll learn how to create a GUI Java calculator from scratch using Java Swing and NetBeans IDE.
This video is perfect for Java beginners who want to understand how to design a Java Swing GUI tutorial in NetBeans and implement the logic behind a simple calculator project.
🔥 What You’ll Learn:
How to create a Java Swing GUI in NetBeans
Step-by-step Java calculator tutorial
Full explanation of Swing components and event handling
Build and run a complete Java calculator project
Tips to make your calculator smarter with AI-based logic
By the end of this tutorial Java Swing, you’ll have a working Java calculator app with buttons, display, and functional operations.
Show More Show Less View Video Transcript
0:00
Hi friends, welcome to tutors funny
0:02
channel. Today I'm going to teach how to
0:04
make the calculator using Java swing
0:08
application with AI. So the AI
0:12
technology will grow very fast. We can
0:15
do the programming. We can complete the
0:18
program very fast. Okay. So
0:21
I have just type on the
0:24
uh online using cha
0:28
Java calculator using net bits just
0:32
just I just what I just type in the
0:35
simple English Java calculator using
0:38
net. So GBT provide the steps to create
0:42
the calculator. So yeah go to the net
0:45
pins how to open the net pins and
0:47
everything it taught me from the
0:50
scratch. Okay. So how simply how to open
0:53
the frame and everything. Okay. That it
0:57
is it is shown as the UI design as well.
1:01
This how that UI design also design.
1:04
Okay. So we have to design the UI design
1:07
based on this image. So that that all
1:10
things they they display uh for us to
1:13
understand easily. Okay. Easily we have
1:16
to create the uh calculator
1:19
along with this documentation. Okay. So
1:22
let's create the UI design first. Right.
1:25
So open up the net bins. So file new
1:29
project. Here I'm going to go to select
1:33
Java with Java application. Click next.
1:36
For this create main class I uncheck it.
1:37
Here I'm going to create that project
1:39
project name is Java Java Cal
1:44
calculator.
1:50
For this create main class you have to
1:52
uncheck it. Click okay.
1:57
Now here the project has been created.
1:59
Calculator source package default
2:00
package. Select this one. New Java frame
2:03
form. You have to select this one
2:04
calculator.
2:09
Click finish.
2:13
Now here you have to increase or
2:15
decrease the frame size. What you need?
2:19
Okay. As you wish. You can increase or
2:21
discre the frame size as you wish. Now I
2:25
I wish to increase the size look like
2:28
this where
2:29
this is fine for me. Okay. This is fine
2:33
for me. Okay. So now what I'm going to
2:36
do is I want to uh design the
2:39
calculator. So design the calculator. So
2:41
what you're going to this this this one
2:43
we can't do by the designing stuff we
2:45
can't do by the AI. So we have to do our
2:47
own one. So we have to drag one panel
2:50
first. First first of all we have to
2:52
drag on the panel.
2:54
Okay. This panel
2:56
we have to name it as
3:02
we have to this one panel. Okay. So we
3:05
let's moving to like this.
3:09
Okay.
3:11
So first right click the frame
3:13
properties port generate center. After
3:16
that what you have done is go to the
3:18
source control F select UI press enter
3:22
key enter key enter key you have write
3:25
matter
3:28
okay it's choosing matter okay now what
3:31
I'm going to is select this one frame
3:34
properties
3:36
you have to select this one if you want
3:39
you can change the background color I
3:41
keep as it is okay now what you going to
3:43
do here this one I want to drag one text
3:47
field.
3:49
It's a text field.
3:52
Make it as like this.
3:57
Okay. Like this. Simple.
4:00
This one. Right click properties.
4:03
Increase the font little bit bigger. 36
4:06
would be fine for me.
4:09
Any 36 with bold. Click okay. Okay. Now
4:14
let's right click change variable txt
4:17
cal
4:20
for txt total
4:25
right click edit text back to remove the
4:27
existing text that's it
4:30
after that I want to buttons
4:38
this one button first button one right
4:42
click properties is
4:46
24 with bold. Click okay
4:52
size I'm going to mention. Okay, this is
4:55
enough for me. The same thing I'm going
4:57
to get the button
4:59
all the Ctrl C to copy. Ctrl V to paste
5:03
and get another copy the same button.
5:06
Ctrl C to copy. Ctrl V to paste and get
5:08
the another copy of the button. Okay, we
5:10
have to get the buttons. Okay, now let's
5:13
back to my design. My design is look
5:16
like this. 7 8 9 7 8 9. Okay, it's no
5:21
problem. 187 after that. Another symbol
5:24
is Yeah. So, Ctrl C to copy another
5:27
symbol is this which is
5:31
this.
5:34
Now what I'm going to something we have
5:35
to arrange the
5:37
size little bit space we have to talk
5:39
about the spacers
6:00
like
6:19
Okay,
6:21
perfectly we done. So this one will be
6:24
two. This one will be the three.
6:28
Okay. So, this same thing. Select all
6:31
the things. Ctrl + C to copy. Ctrl + V
6:32
to paste below.
6:35
Ctrl C to copy. Control V to paste
6:38
below.
6:48
Okay. So, here same thing. Ctrl C to
6:51
copy. Ctrl V to paste below.
6:58
Let's arrange them.
7:29
You might have to size. We have to
7:33
arrange like this. Simple. We have to
7:35
arrange.
7:38
Okay. This is simple one. We have to
7:40
arrange it. Size all things. We have to
7:41
arrange properly.
7:48
Okay. Simple.
7:51
Okay. Right. Now what I'm going to do is
7:54
now let's do the things like this. So
7:56
now we have simply we have to UI design
7:58
we have completed. So that we have to
8:00
get 61. 4
8:03
5
8:06
6
8:09
7
8:13
8
8:15
9
8:19
Make a K to plus
8:25
minus.
8:28
Okay. So let's move into here
8:32
multiplication
8:35
service multiplication. Okay. After that
8:38
what I'm going to do we have to we have
8:40
this symbol. So we need zero C
8:45
0
8:50
clear means C. It stands for C mean
8:52
clear
8:54
equal.
8:58
Simple calcate
9:01
the simple calcate. So let me check it.
9:11
We have complete the UI design.
9:15
We complete the UI design. Okay. Now
9:17
let's feel I feel little bit
9:20
space between between that. So let's say
9:23
right.
9:27
Okay.
9:37
Okay.
9:40
The frame.
9:46
Okay. Perfect. Okay. This is perfect.
9:48
Calculator.
10:03
It's a perfect calculator. Now you can
10:05
you'll be able to see the perfect look
10:07
calculator. I have some calculator. Now
10:09
first what I'm going to you have to go
10:11
based on AI mode. The first one I'm
10:13
going to select this one. What the name
10:15
you have given you go based on the
10:17
documentation.
10:21
So this one this uh total I have this
10:23
one uh first text box. Okay, that's one
10:26
we have to write it here. Uh number one
10:29
number two likewise over here go back
10:33
and now here first one what I'm going to
10:34
do is we have the first number one text
10:37
box btn one mean text box. So what
10:41
you're going to see here code
10:43
this one right click event action action
10:47
perform what I'm going this one button
10:49
one okay here what is the things we have
10:52
to we have to name it this one as a t
10:54
not total we have to display what's the
10:56
given
10:57
tx display this textbox name
11:01
okay t display this textbox name so
11:05
right click event action action perform
11:09
now let's copy this code and paste on it
11:12
because when you press A when you press
11:16
A this is for a text box press a click a
11:20
one
11:21
it's going one should be display on this
11:24
text box this text has become one
11:28
example
11:31
one one has been display
11:34
the same thing like that where two as
11:35
well you have to apply okay in AI not
11:39
provide everything. So you have the user
11:41
you have to pick copy double click on it
11:46
instead of uh do it simply double click
11:50
and apply two
11:52
3
12:01
4
12:07
I will
12:14
6
12:22
7
12:29
8
12:34
9
12:45
okay
12:48
now we have all the numbers I have set
12:50
it successfully now you can check you
12:52
can check your name whether it's working
12:53
fine or not 8 six all things are working
12:56
fine
12:58
now what I'm going to do is back on my
13:00
AI
13:03
uh now here
13:06
make here I want to add these numbers we
13:08
have to calculate that how to calculate
13:09
them what is here these are the numbers
13:15
okay so how to convert this one also
13:17
second one we have to add this one this
13:18
box copy this first we have to implement
13:23
this things copy this
13:26
paste on it above
13:29
here we have to declaring the double
13:32
data type we have a three we have
13:34
created three various three different
13:37
variables
13:38
okay number one number two and result
13:40
one SH variable which is operate we have
13:43
created successfully now what I'm going
13:45
to see here I want to plus double click
13:49
on the plus symbol
13:53
what I'm going to here
14:00
copy this code first or paste on it over
14:03
here.
14:06
Okay. Paste on it here.
14:09
When you click plus, it's work on this.
14:14
After that, when you click minus,
14:17
work on this. When you say number minus,
14:21
you have to here also minus.
14:24
Okay. After that, when the number is
14:28
minus, okay.
14:31
Plus
14:36
this is subtraction sorry division mark.
14:40
Okay.
14:42
Third one is just this copy this
14:47
minus
14:51
after that
14:53
subtraction.
15:02
Okay. After that what you going to do is
15:04
after that gra things are fine. So I
15:06
want to call the things things on the
15:10
equal button.
15:12
is equal double click on it paste on the
15:15
code over here.
15:19
Okay. When you give the second number
15:22
and here if it is if you select the plus
15:24
if you click plus symbol already it will
15:26
be calculate the the two numbers added
15:30
and result will be display. If you
15:33
select as minus it will be
15:37
do the calculation part and result will
15:40
be display
15:41
uh display display according to the
15:44
calculation. Okay. This here is multiply
15:47
the result will be displayed. Okay. So
15:49
that's why we have the case which case
15:51
is support when case if it is plus minus
15:55
subtraction or division. Okay. According
15:56
to the symbol it it has been working
15:59
very simple. Okay. This how we have do
16:02
it. Okay. Finally another one we have to
16:04
forgot to write that one is a clear
16:07
display clear copy this
16:10
only clear this one you have to clear
16:12
the one
16:14
simple calculator part we have done it
16:16
from the let's check it whether it's
16:19
working fine or not
16:22
one plus subtract this one 8
16:28
answer will be eight working fine okay
16:31
so now click here
16:34
45 + 45
16:38
answer will be 90 working perfectly well
16:42
okay again I'm clear
16:46
12
16:47
divide 12
16:50
answer will be one working perfectly I
16:53
hope you guys you understood things well
16:55
if you have any doubt you can ask me any
16:57
time if you love my channel please
16:59
subscribe me like me thank you for
17:01
watching
17:02
This also all the source code I provide
17:04
you in my video description. You will be
17:06
able to download it. Thank you for
17:07
watching.
#Programming
#Java (Programming Language)

