create account

Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program] by official-hord

View this thread on: hive.blogpeakd.comecency.com
· @official-hord · (edited)
$106.39
Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]
![sample.jpg](https://steemitimages.com/DQmfVo5V5vpMNgPHngUDaqsksk6nRRhdwxiKfzmFWF4ovU2/sample.jpg)

Hi Steemians, from our first tutorial we were able to successfully install the NetBeans 8.2 software and Jdk 8u151 platform, So today we will be learning about our NetBeans application environment, different tabs and their uses, and also creating our java JFrame first program, I hope you enjoy this.
******
Lets Begin:

Open Netbeans 8.2  (The one we installed [Here](https://steemit.com/javaprogramming/@official-hord/java-programming-tutorial-introduction-installing-java-jdk-netbeans-and-sqlitestudio)) on your desktop,
Should display this if its working: 
![newapplication1.jpg](https://steemitimages.com/DQmarAkKz855vHcv1wcCnSqQ7iE7khsuF3HBuDZnLx7XZKm/newapplication1.jpg)


Straight to work.

## Stage one: Creating a new Project file
In this stage I’ll be showing you how to create a java application project file, in which we will be storing all files related to the application we would write during the course of this tutorial.


# STEP 1: 
Click the file menu, go to new project in the drop-down list and click on it.

![newapplication2.jpg](https://steemitimages.com/DQmVZUBcRvzm8wT5oWs6PPXcfDWFqEjfPp8nVvptN8YdEtm/newapplication2.jpg)


# STEP 2: 
Click on Java under the categories list, and click on Java application on the Projects list. Finally click the next button beneath the Description.


# STEP 3: 
A new window opens in it, you would be required to enter the name of you want to give your application, where you want it to be stored and whether or not to create a main class file for the application. Do set the name you want in the Project name space and leave the destination alone for now, we would discuss that later. Also uncheck the create a main class option and click Finish.
![newapplication3.jpg](https://steemitimages.com/DQmZj31QbmYDLt9YUGW3Cpo7MiNtv7YFVP8ia4th1zeWNwi/newapplication3.jpg)


We just Created a new java application project file, which is currently empty because we have not created any source files yet.

**Source Files:** 
>These are files written by the programmer which a lay man would not understand, these files are like the engine of any program and without them there cannot be a program.


## Stage 2: To our First Java Application
We have successfully created a file for the source files of our application to be saved, so now we begin creating our first program, like I explained earlier source files are the engines of our program, now source files are stored in what we call source packages, if you look at your screen you would notice somewhere under the application name on the right top corner of your screen something called source packages, that’s it so let’s create a source file under default packages.


# STEP 1: 
Click the minus or plus sign beside your application name, to reveal source packages, do same for source packages and right click default packages, go to new, click on Jframe form.
![newapplication4.jpg](https://steemitimages.com/DQmV3uG22hhCMpVfw3sLYt5NbHDyMFHpLEBR9FUmnek4QDo/newapplication4.jpg)


# STEP 2: 
I mentioned something about not creating a main class earlier, a source file contains a class, I don’t want you to see that as something really tedious, it’s just same definition as a regular classroom. So, set your class name to whatever you want but I’ll prefer you use example1 like I used. Click finish and we are done creating our first source file.
![newapplication5.jpg](https://steemitimages.com/DQmbUbRnvaHXiXaGKbgijbXiL1pkJ9S9THbmYqw7Z5wuJo9/newapplication5.jpg)


If you notice, there’s an empty box inside the design view, that is called a jframe form (what we just created) 
Let’s fill up some space together…. Go to section 5 in the previous picture, click and hold onto text field and drag into the empty space in the frame you have just created.


## Stage 3 - Adding components to the JFrame form:

# STEP 1: 
Click and hold down left mouse button on any item from the palette, drag into the frame and drop.

# STEP 2: Increase size to desired.

![tutorial6t.jpg](https://steemitimages.com/DQmYgLcQtVUuzv7FHFdce6H1EXfFmNEHNbV9fVG4UY4gjve/tutorial6t.jpg)

We’ll be adding 
1.	A textfield
2.	A button
3.	A label
Feel free to go ahead and add them yourself, they are all in the swing controls area of the palette.

![tutorial7.jpg](https://steemitimages.com/DQmWS2HJk5ie5dZz1Vx3gyrdZ4kXmKT6jgkVo8wcTsjR2Dt/tutorial7.jpg)


## Stage 4 - Making the save Button work:


# STEP 1: 
Right click on the textfield you have created and click on change variable name, clear the current name and enter username.


# STEP 2: 
Right click on the save button, go to events, then action, and click actionperformed…. You will enter the source code area, don’t be scared you didn’t spoil anything. You can go back to your design by clicking design tab beside the source tab on top of the source code area.
![tutorial8.jpg](https://steemitimages.com/DQmYZQDsNYY4JnVupR45fpdK7pJohMUa7oRaGv73fXR4BpR/tutorial8.jpg)


# STEP 3: 
Call a string variable to store the username you’ll input… 
`String usernametext = username.getText(); `


# STEP 4: 
Now go back to your design view by clicking the design tab, right click on the label you placed and change the variable name to “output”, then right click on your button, go to Events, Actions, and click action performed. Go to the end of the previous line you entered and press the enter key, type this:
`output.setText(output.getText()+usernametext);`
![tutorial9.jpg](https://steemitimages.com/DQmSUSvwj4E644c8PTpbXWQ31Y52tzTfH6FEeSGaU8jMdxK/tutorial9.jpg)


Finally, Right click inside the code and click run, wait for it to load and enter your name in the text region, click save and your name appears in the label.
![tutorial10.jpg](https://steemitimages.com/DQmedAXy36DztcVmYrus9tZSrFQuwSHKc9H36Bf9hu1cRs2/tutorial10.jpg)


We have successfully built our first program, called example1.
Heres what example1 can do:
1.	Accept input of username.
2.	Save input username.
3.	Output the username when the save button is clicked.

### Here's a video to help you out, do follow carefully

https://www.youtube.com/watch?v=PAL2pXGPzlg

Congratulations !!!
Hope to see you in the next tutorial.

Subscribe to my [Youtube Channel](https://www.youtube.com/channel/UCBLJW4vUbw4KyJhvtf-0qMA)
Also know how to [Install](https://steemit.com/javaprogramming/@official-hord/java-programming-tutorial-introduction-installing-java-jdk-netbeans-and-sqlitestudio) Netbeans 8.2 Ide, Jva JDK and Sqlite Studio.

_This is me and my Laptop, I call it my baby, my girlfriend_
![IMG_20171204_195534.jpg](https://steemitimages.com/DQmPwVA3sSxyDWeqkKzHVwiSDGzpV6m6yDwuwvf6Vp3CbGG/IMG_20171204_195534.jpg)

**Note**
1. All screenshots in this post where taken personally from my laptop screen by me and edited with paint.
2. Video was captured using Bandicam free version and edited with bandicut, from bandicam.com.
3. This video hasn't been posted anywhere else apart from my Youtube channel .
4. This was not copied from anywhere as it was 100% authored by me.
![DQmZkyG7SyJiSNN6qkxJ9n9darqn51RjWpDnJCKYKEhx3D4.gif](https://steemitimages.com/DQmZkyG7SyJiSNN6qkxJ9n9darqn51RjWpDnJCKYKEhx3D4/DQmZkyG7SyJiSNN6qkxJ9n9darqn51RjWpDnJCKYKEhx3D4.gif)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 34 others
properties (23)
authorofficial-hord
permlinkjava-programming-tutorial-with-official-hord-creating-our-first-jframe-program
categoryjavaprogramming
json_metadata{"links":["https://steemit.com/javaprogramming/@official-hord/java-programming-tutorial-introduction-installing-java-jdk-netbeans-and-sqlitestudio","https://www.youtube.com/watch?v=PAL2pXGPzlg","https://www.youtube.com/channel/UCBLJW4vUbw4KyJhvtf-0qMA","https://steemit.com/javaprogramming/@official-hord/java-programming-tutorial-introduction-installing-java-jdk-netbeans-and-sqlitestudio"],"image":["https://steemitimages.com/DQmfVo5V5vpMNgPHngUDaqsksk6nRRhdwxiKfzmFWF4ovU2/sample.jpg","https://steemitimages.com/DQmarAkKz855vHcv1wcCnSqQ7iE7khsuF3HBuDZnLx7XZKm/newapplication1.jpg","https://steemitimages.com/DQmVZUBcRvzm8wT5oWs6PPXcfDWFqEjfPp8nVvptN8YdEtm/newapplication2.jpg","https://steemitimages.com/DQmZj31QbmYDLt9YUGW3Cpo7MiNtv7YFVP8ia4th1zeWNwi/newapplication3.jpg","https://steemitimages.com/DQmV3uG22hhCMpVfw3sLYt5NbHDyMFHpLEBR9FUmnek4QDo/newapplication4.jpg","https://steemitimages.com/DQmbUbRnvaHXiXaGKbgijbXiL1pkJ9S9THbmYqw7Z5wuJo9/newapplication5.jpg","https://steemitimages.com/DQmYgLcQtVUuzv7FHFdce6H1EXfFmNEHNbV9fVG4UY4gjve/tutorial6t.jpg","https://steemitimages.com/DQmWS2HJk5ie5dZz1Vx3gyrdZ4kXmKT6jgkVo8wcTsjR2Dt/tutorial7.jpg","https://steemitimages.com/DQmYZQDsNYY4JnVupR45fpdK7pJohMUa7oRaGv73fXR4BpR/tutorial8.jpg","https://steemitimages.com/DQmSUSvwj4E644c8PTpbXWQ31Y52tzTfH6FEeSGaU8jMdxK/tutorial9.jpg","https://steemitimages.com/DQmedAXy36DztcVmYrus9tZSrFQuwSHKc9H36Bf9hu1cRs2/tutorial10.jpg","https://steemitimages.com/DQmPwVA3sSxyDWeqkKzHVwiSDGzpV6m6yDwuwvf6Vp3CbGG/IMG_20171204_195534.jpg","https://steemitimages.com/DQmZkyG7SyJiSNN6qkxJ9n9darqn51RjWpDnJCKYKEhx3D4/DQmZkyG7SyJiSNN6qkxJ9n9darqn51RjWpDnJCKYKEhx3D4.gif"],"tags":["javaprogramming","steemstem","science","coding","tutorial"],"app":"esteem/1.5.0","format":"markdown+html","community":"esteem"}
created2017-12-04 14:57:48
last_update2017-12-05 11:26:33
depth0
children10
last_payout2017-12-11 14:57:48
cashout_time1969-12-31 23:59:59
total_payout_value80.180 HBD
curator_payout_value26.214 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,263
author_reputation8,938,440,857,429
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,370,070
net_rshares28,621,122,230,803
author_curate_reward""
vote details (98)
@carlgnash ·
$0.09
This is a great post!  Really glad to see you continuing this series.  I love the way you did the screencaps with numbering so you could refer to the same screencap for multiple steps - totally going to steal that idea for my own tutorial posts!  You have written everything in a very clear and easy to follow format.  Just a great job all the way around.  Cheers - Carl
👍  ,
properties (23)
authorcarlgnash
permlinkre-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171204t231545516z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"app":"steemit/0.1"}
created2017-12-04 23:15:48
last_update2017-12-04 23:15:48
depth1
children1
last_payout2017-12-11 23:15:48
cashout_time1969-12-31 23:59:59
total_payout_value0.072 HBD
curator_payout_value0.020 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length370
author_reputation114,786,060,260,950
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,408,137
net_rshares25,782,642,722
author_curate_reward""
vote details (2)
@official-hord ·
Thanks a lot carl, theres more coming and i hope you like them... Hey stealing is bad lol.
properties (22)
authorofficial-hord
permlinkre-carlgnash-re-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171205t052831671z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"app":"steemit/0.1"}
created2017-12-05 05:28:27
last_update2017-12-05 05:28:27
depth2
children0
last_payout2017-12-12 05:28:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length90
author_reputation8,938,440,857,429
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,429,627
net_rshares0
@christianjombo ·
Great Post. Just followed you. I build web apps and look forward to learning from you.
properties (22)
authorchristianjombo
permlinkre-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20180125t113051602z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"app":"steemit/0.1"}
created2018-01-25 11:30:54
last_update2018-01-25 11:30:54
depth1
children0
last_payout2018-02-01 11:30:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length86
author_reputation132,777,965,075
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,177,450
net_rshares0
@diegoferrer ·
excellent post I follow you, if you want you can follow me
properties (22)
authordiegoferrer
permlinkre-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171206t030114066z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"app":"steemit/0.1"}
created2017-12-06 03:01:18
last_update2017-12-06 03:01:18
depth1
children1
last_payout2017-12-13 03:01:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length58
author_reputation-291,113,965,769
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,523,769
net_rshares0
@official-hord ·
Thanks @diegoferrer... would do same ASAP
properties (22)
authorofficial-hord
permlinkre-diegoferrer-re-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171206t115924691z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"users":["diegoferrer"],"app":"steemit/0.1"}
created2017-12-06 11:59:24
last_update2017-12-06 11:59:24
depth2
children0
last_payout2017-12-13 11:59:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length41
author_reputation8,938,440,857,429
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,557,881
net_rshares0
@ewuoso ·
this is explanatory, i like it. i did not know anything about java programming before but i have been following since yhu did the first tutorial. thanks for sharing
properties (22)
authorewuoso
permlinkre-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171204t191513177z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"app":"steemit/0.1"}
created2017-12-04 19:15:21
last_update2017-12-04 19:15:21
depth1
children0
last_payout2017-12-11 19:15:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length164
author_reputation26,172,031,786,404
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,391,743
net_rshares0
@justtryme90 · (edited)
You spelled our tag wrong :p

#steemstem not steemsten

Nice job on the post
properties (22)
authorjusttryme90
permlinkre-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171205t003111139z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming","steemstem"],"app":"steemit/0.1"}
created2017-12-05 00:31:15
last_update2017-12-05 00:31:36
depth1
children1
last_payout2017-12-12 00:31:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length76
author_reputation140,118,479,939,905
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,412,520
net_rshares0
@official-hord ·
$0.13
Owwww typographc error @justtryme, corrected. Thanks for the upvote too.
👍  
properties (23)
authorofficial-hord
permlinkre-justtryme90-re-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171205t052913616z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"users":["justtryme"],"app":"steemit/0.1"}
created2017-12-05 05:29:12
last_update2017-12-05 05:29:12
depth2
children0
last_payout2017-12-12 05:29:12
cashout_time1969-12-31 23:59:59
total_payout_value0.096 HBD
curator_payout_value0.032 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length72
author_reputation8,938,440,857,429
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,429,658
net_rshares35,376,425,718
author_curate_reward""
vote details (1)
@tensor ·
Very high quality post.  I really dislike java (personal reasons), but I've been seeing some nice java programming tutorials on steemit lately.  I'm glad I am not the only one doing Educational Programming content on steemit.
properties (22)
authortensor
permlinkre-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171206t085059437z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"app":"steemit/0.1"}
created2017-12-06 08:50:57
last_update2017-12-06 08:50:57
depth1
children1
last_payout2017-12-13 08:50:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length225
author_reputation87,856,203,149,624
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,545,471
net_rshares0
@official-hord ·
Lol.... Thats sweet to hear, thanks a lot @tensor, hope you keep following, would checkout your blog ASAP
properties (22)
authorofficial-hord
permlinkre-tensor-re-official-hord-java-programming-tutorial-with-official-hord-creating-our-first-jframe-program-20171206t120023972z
categoryjavaprogramming
json_metadata{"tags":["javaprogramming"],"users":["tensor"],"app":"steemit/0.1"}
created2017-12-06 12:00:27
last_update2017-12-06 12:00:27
depth2
children0
last_payout2017-12-13 12:00:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length105
author_reputation8,938,440,857,429
root_title"Java Programming tutorial 2 with @officialhord - [Creating our first JFrame Program]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id22,557,967
net_rshares0