Learn how to build your first Java GUI application from scratch in this beginner-friendly tutorial! In this step-by-step guide, we’ll walk you through creating a professional login system using Java Swing, complete with a user-friendly interface and seamless navigation between frames. Perfect for beginners, this tutorial covers Java GUI basics, JFrame setup, login form design, and moving from one frame to another with practical examples. No prior experience required! Follow along to master Java GUI programming and create your own login application today.
00:00Hello friends, in this video I'll teach you how you can create your first GUI application
00:05in NetBeans.
00:06Ok.
00:07So let's start.
00:08You have to click on this yellow icon.
00:11And here you can see an option Java and Java application.
00:16Click next.
00:18And name your application MyFirstJavaGUI ok.
00:26Name whatever you want ok.
00:28And don't create, uncheck this one ok.
00:31Because we don't need main glass.
00:35And finish.
00:36So it will take some time to create a project for you.
00:40You can see our first GUI project is ready.
00:43Now what we have to do.
00:45You can see.
00:47You have to click on our project ok.
00:51And create a new JFrameform ok.
00:55So I name it as login and finish.
01:09So you can see.
01:10I simply adjust it.
01:20And here I have to take a panel and put it here.
01:24You may put anything ok.
01:26From here to create your required GUI.
01:28So I take a panel and put it here.
01:32To set it in the background ok.
01:36And open properties.
01:39Once you right click on your J panel ok.
01:42A properties option.
01:45You may see a properties here ok.
01:48So here you may change the background color.
01:53So I wanna set a green background color.
01:56Ok.
01:57And close.
01:58So you can see.
02:07And then I have to take a label and put it here.
02:10And name it as login.
02:14Ok.
02:15Change the color to white.
02:19So you can see.
02:20You have to change the foreground color.
02:24And make it white.
02:26Ok.
02:27It's 24 and bold.
02:33So I think it's look better.
02:36Now.
02:37And you have to take a user name.
02:43Ok.
02:48So.
02:49Let me make.
02:51Set the font size to 36 ok.
02:53So here I have to type user name.
03:04Username.
03:05Username.
03:06That we have to take the user name and password ok.
03:11So user name.
03:14And properties.
03:15From properties you may change the background.
03:20Ok.
03:21So the foreground color.
03:22Or font size ok.
03:25So I set white.
03:28And 18 bold ok.
03:31And make it as bold ok.
03:38So once you click here.
03:42You may type control D to duplicate it.
03:45Duplicate ok.
03:46So name it as.
03:48Change the text to password ok.
03:51That's all.
03:52And what you have to do now.
03:53You have to take one.
03:54Text field and one password field ok.
03:55So you can see.
03:56I simply drag and drop it here.
03:57Taking user name.
03:58And password.
03:59So this one is our password field.
04:00So I have to put it here.
04:01And adjust it.
04:02You can see.
04:03You can see.
04:04Our interface is now ready.
04:05So double click it here.
04:06So we have to put it here.
04:07And adjust it.
04:08You can see.
04:09Our interface is now ready.
04:10So double click it here.
04:11So do what.
04:12You can see.
04:13There are two parts.
04:14Okay.
04:15A design part and a source part.
04:17Ok.
04:18Here we have to write the back end logic.
04:19And here we have to design.
04:20Okay.
04:21So first of all edit text to.
04:23it you can see our interface is now ready so double click it here so do what you
04:31can see there are two parts okay a design part and the source part okay here we
04:35have to write the backend logic and here we have to design okay so first of all
04:40edit text to null and password also set to null and take a button
04:50okay submit
05:09so let's first run and check the interface okay our interface look like our main
05:15class is login so this is how our interface look like okay you can see it
05:23appear in the top left corner okay so how to set it in the middle of screen it's
05:30too easy you have to you can see you have to open navigator okay and select this
05:38j frame and properties okay then click in code and you can see there is an option
05:48generate center okay generate resize code and generate center and click close now
05:58once you run this one it open in the middle of screen you can see now it's time
06:08to design a new frame new j frame form and name it as home page
06:25so this one is our home page take a panel put it here
06:38properties
06:42properties
06:42set the color to green okay
06:50and put a label here
06:59ready text welcome to home page okay that's all same like that open properties and change the phone
07:15family and phone size okay
07:17bold and what we have to do
07:25text color white okay and close also click it here properties code generate resize code generate center okay and close
07:53so you have to change the variable names okay change the variable name aware we have to put text okay so these are the text field
08:09it's user name user name and change variable name to pass okay because we have to get the text that entered by user okay with these variables so once you click on this subnet button double click okay or you may right click properties
08:34events
08:38events okay you can see action performed okay
08:42double click it here and you will go in the implementation in the source part okay so what we have to do here
08:52first of all we have to get the password and user name okay so we have to create two string variables
09:04user name
09:06user name which is equal to
09:08user name dot
09:10user name dot
09:12get text okay
09:14user name dot
09:16get text okay
09:18string
09:20user pass which is equal to
09:24pass dot get
09:26text okay
09:28text okay
09:34let's capital
09:36here what we have to do we have to check okay
09:40if
09:42un dot equals
09:48like
09:52billar
09:54and
09:56password dot
09:58password dot
10:00equals
10:02one two three four
10:06then we allow to login
10:08otherwise
10:10we display an error message okay
10:12else
10:22j option
10:24password
10:30show message dialogue okay
10:32show message dialogue okay
10:36what we have to pass here simply
10:40null
10:46invalid
10:48user name
10:50password
10:52or password okay
10:58and if it is valid what we have to do we have to create homepage object okay
11:02homepage
11:04which is equal to new of
11:08homepage
11:10hp dot
11:14set
11:16visible
11:18true
11:20this dot set
11:22visible
11:24true
11:26this dot set
11:28visible
11:29true
11:30this dot set
11:32visible
11:33okay
11:34so once once I run this one
11:36if i put a username and put first time invalid password and submit you can see invalid username
11:49or password so what's my password one two three four and submit you can see welcome to home page
11:56so this is where you can create your first application in java with gui hope you like
12:03this video please subscribe my channel for more informative videos bye bye tata see you
Be the first to comment