0:01 hey what's going on everybody it's your
0:03 bro hope you're doing well and in this
0:04 video i'm going to teach you guys how we
0:06 can make a very basic
0:09 gui application in java so sit back relax
0:09 relax
0:15 if you find this video helpful please
0:16 remember to like
0:19 comment and subscribe your support will
0:20 help keep this channel running
0:22 all right guys and gals i'm going to
0:25 teach you all how to create a very basic
0:27 gui program gui is an acronym for graphical
0:28 graphical
0:31 user interface it's a visual program
0:32 that we can see
0:35 and interact with kind of like this
0:38 so we'll be using the j option pane
0:40 class and be creating a few message
0:41 dialog boxes
0:43 before we begin we'll need an import so
0:45 outside your class let's type this
0:49 import java x dot swing
0:53 dot j option pin
0:56 so we will be working with the j option pane
0:56 pane
0:59 class now what we would like to do is
1:01 type in some user information into a
1:02 sort of
1:04 dialog box and we'll store this as a
1:05 string variable called
1:07 name kind of like what we did on the
1:09 video on user input
1:12 string name and in order to create an
1:14 input dialog box we're going to type
1:21 dot and there's a few options what we
1:22 would like is
1:25 show input dialog and you can really
1:26 just pick any of these
1:29 and we can type in a message so with
1:30 this message
1:34 let's state enter your
1:37 name and when we run this
1:40 this is what we have we have the small
1:42 gui dialog box and we can type in our
1:43 name and submit it
1:45 but it currently doesn't do anything so
1:48 let's create another message dialog box
1:49 that will display our name along with a message
1:51 message
1:54 so j option
1:58 pain dot show message
2:02 dialogue for now you can just type in no
2:06 comma and then a message let's say
2:09 hello plus
2:13 name and let's try it so our first
2:16 dialog box is the show input dialog message
2:17 message
2:19 and we can type in our name and submit a name
2:20 name
2:22 and our second box here is a message
2:24 dialog box this just displays some information
2:25 information
2:28 such as a string of text and it says
2:29 hello bro
2:31 this time let's ask for an edge and
2:33 store this value within an integer
2:35 variable called age int
2:37 age equals and we can just copy all of this
2:38 this
2:41 j option pane dot show input dialog
2:44 and the message will be enter your edge
2:46 there is one issue though
2:49 when you use the show input dialog box
2:50 it's going to return
2:53 a string and we're attempting to assign
2:54 the string into an integer
2:57 variable so what we would need to do is
2:58 convert this
3:01 to an integer and there is actually a
3:03 method to do that
3:05 so what i'm going to do is use the integer
3:06 integer
3:09 wrapper class and use the parseint method
3:10 method
3:12 and within the parenthesis we're going
3:15 to take all of this
3:19 and copy it within our parseint method
3:21 and then add a semicolon at the end so
3:22 this will return
3:25 a string based on what the user types in
3:27 and the parseint method will convert it
3:29 to an integer that we can store it
3:31 within our integer variable of age
3:33 and then we can display this so let's
3:35 display this with another
3:38 message dialog box j option pane dot
3:40 show message dialog
3:44 null will be the first argument and our
3:46 message will be
3:50 u r plus age
3:53 plus years old
4:00 enter your name bro press okay
4:02 hello bro then when we click okay again
4:04 it's going to go to our next
4:07 input dialog box enter your age let's
4:08 say that i'm 18
4:12 click ok you are 18 years old now let's
4:19 this time let's create a variable called
4:20 maybe height
4:23 this will be a double value and the
4:25 variable name will be height
4:26 so since we're working with double
4:29 values we're going to change integer to
4:33 double double with a capital d dot parse
4:37 double and the message will be enter
4:41 your height and our message dialog
4:48 and let's say this is in centimeters tall
4:50 tall
4:52 so we have to be sure that we're getting
4:54 the right data type because when you use
4:56 the input dialog box it's going to
4:57 return a string
4:59 so if you're attempting to assign that
5:01 string to a certain data type you have
5:02 to convert it
5:04 to that specific data type so let's try this
5:05 this
5:09 enter your name bro okay hello bro
5:12 what is your age let's say i'm 18 press okay
5:12 okay
5:15 you're 18 years old enter your height i
5:17 don't know what a good height is
5:20 240 centimeters and then click ok
5:24 you are 240.0 centimeters tall
5:25 in conclusion ladies and gentlemen what
5:27 we have made is a
5:29 very simple graphical user interface for fun
5:30 fun
5:32 this is completely optional at this
5:34 point but we will be learning more about
5:36 gooeys later in this playlist
5:37 so if you would like a copy of all this
5:39 code i will post all of this in the
5:40 comments down below
5:42 and if you could do me a favor down
5:44 below smash the like button
5:46 drop a comment and subscribe if you'd