Skip watching entire videos - get the full transcript, search for keywords, and copy with one click.
Share:
Video Transcript
hey what's going on everybody it's your
bro hope you're doing well and in this
video i'm going to teach you guys how we
can make a very basic
gui application in java so sit back relax
relax
if you find this video helpful please
remember to like
comment and subscribe your support will
help keep this channel running
all right guys and gals i'm going to
teach you all how to create a very basic
gui program gui is an acronym for graphical
graphical
user interface it's a visual program
that we can see
and interact with kind of like this
so we'll be using the j option pane
class and be creating a few message
dialog boxes
before we begin we'll need an import so
outside your class let's type this
import java x dot swing
dot j option pin
so we will be working with the j option pane
pane
class now what we would like to do is
type in some user information into a
sort of
dialog box and we'll store this as a
string variable called
name kind of like what we did on the
video on user input
string name and in order to create an
input dialog box we're going to type
dot and there's a few options what we
would like is
show input dialog and you can really
just pick any of these
and we can type in a message so with
this message
let's state enter your
name and when we run this
this is what we have we have the small
gui dialog box and we can type in our
name and submit it
but it currently doesn't do anything so
let's create another message dialog box
that will display our name along with a message
message
so j option
pain dot show message
dialogue for now you can just type in no
comma and then a message let's say
hello plus
name and let's try it so our first
dialog box is the show input dialog message
message
and we can type in our name and submit a name
name
and our second box here is a message
dialog box this just displays some information
information
such as a string of text and it says
hello bro
this time let's ask for an edge and
store this value within an integer
variable called age int
age equals and we can just copy all of this
this
j option pane dot show input dialog
and the message will be enter your edge
there is one issue though
when you use the show input dialog box
it's going to return
a string and we're attempting to assign
the string into an integer
variable so what we would need to do is
convert this
to an integer and there is actually a
method to do that
so what i'm going to do is use the integer
integer
wrapper class and use the parseint method
method
and within the parenthesis we're going
to take all of this
and copy it within our parseint method
and then add a semicolon at the end so
this will return
a string based on what the user types in
and the parseint method will convert it
to an integer that we can store it
within our integer variable of age
and then we can display this so let's
display this with another
message dialog box j option pane dot
show message dialog
null will be the first argument and our
message will be
u r plus age
plus years old
enter your name bro press okay
hello bro then when we click okay again
it's going to go to our next
input dialog box enter your age let's
say that i'm 18
click ok you are 18 years old now let's
this time let's create a variable called
maybe height
this will be a double value and the
variable name will be height
so since we're working with double
values we're going to change integer to
double double with a capital d dot parse
double and the message will be enter
your height and our message dialog
and let's say this is in centimeters tall
tall
so we have to be sure that we're getting
the right data type because when you use
the input dialog box it's going to
return a string
so if you're attempting to assign that
string to a certain data type you have
to convert it
to that specific data type so let's try this
this
enter your name bro okay hello bro
what is your age let's say i'm 18 press okay
okay
you're 18 years old enter your height i
don't know what a good height is
240 centimeters and then click ok
you are 240.0 centimeters tall
in conclusion ladies and gentlemen what
we have made is a
very simple graphical user interface for fun
fun
this is completely optional at this
point but we will be learning more about
gooeys later in this playlist
so if you would like a copy of all this
code i will post all of this in the
comments down below
and if you could do me a favor down
below smash the like button
drop a comment and subscribe if you'd
Click on any text or timestamp to jump to that moment in the video
Share:
Most transcripts ready in under 5 seconds
One-Click Copy125+ LanguagesSearch ContentJump to Timestamps
Paste YouTube URL
Enter any YouTube video link to get the full transcript
Transcript Extraction Form
Most transcripts ready in under 5 seconds
Get Our Chrome Extension
Get transcripts instantly without leaving YouTube. Install our Chrome extension for one-click access to any video's transcript directly on the watch page.