Hang tight while we fetch the video data and transcripts. This only takes a moment.
Connecting to YouTube player…
Fetching transcript data…
We’ll display the transcript, summary, and all view options as soon as everything loads.
Next steps
Loading transcript tools…
Hello World | Java Swing Tutorial for Beginners | Java Code Junkie | YouTubeToText
YouTube Transcript: Hello World | Java Swing Tutorial for Beginners
Skip watching entire videos - get the full transcript, search for keywords, and copy with one click.
Share:
Video Transcript
hi this is dave from javacodejunkie.com
and welcome to the first in a new series
of tutorials on
java swing in this video we're going to
write our first
java swing gui program so let's get
right to it
let's go to eclipse and create a new
java project i'm going to call this
for my first swing project click finish
and then i'm going to create a new package
package
click finish and i'm going to create
two classes the first is going to be
a class that i always use to start a
program and it's called launcher
i'll create a main method in that
click finish and then the second
no main method and click finish
so let's go back to our launcher class
and in the launcher class
we're going to use a method from the
swing utilities class
the invoke later method requires as a parameter
parameter
a an instance of runnable the swing
utilities.invokelater method
will ensure that all of our swing
related code is run
on the same thread and that thread is
called the event
dispatch thread and it's done that way because
because
swing is not thread safe so
all swing code has to run in the same thread
thread
so we'll do this once and we never have
to think about it ever again so i'm
going to create
and then we will override the run method
which is the only
method specified in the runnable
interface and in that method what we're
going to do
is create a new instance of our
and then i'll do a main dot show
now this has not yet been written so
we're going to get an error at this
point but
let's not worry about that we're going
to take care of that right away
we'll move now to the main window class
and in the main window class i'm going
to create an instance variable
of type jframe and jframe is the top
organize the imports create a constructor
and we'll also create a method called show
so now if we go back to our launcher we
no longer have an error
so in our constructor i'm going to create
create
i'm going to use a method of the jframe
i'm going to set an option that defines
what's going to happen when we click the
x in the top right hand corner of the
window to close the window the default
is to
do nothing and what it actually does is
it just hides the window so what we want
to happen when we click it
is to close or dispose of the window
default close operation
j frame dot
dispose on close we're going to set
we'll make it 800
and to center the window on the screen
we'll call another method
set location relative to and setting
it relative to null actually centers it
on the screen
and in the show method we'll simply say window
window
dot set visible true
and now if we run we should see a window
with a title that says hello world
in this video tutorial we created our
first java
swing program if you enjoyed the
tutorial please click the thumbs up to
like the video
also please consider subscribing to the
channel to view
more java swing videos thanks for
hanging out with me today
and until next time stay safe and keep
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.