Make GUI Display (Swing) in Java

Posted on: January 18, 2011

In this post, I take one example for built GUI Display in Java, and I decide to make  GUI Display in Hanoi Tower.


The Tower Hanoi or Towers of Hanoi , also called the Tower of Brahma or Towers of Brahma, is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.

The objective of the puzzle is to move the entire stack to another rod, obeying the following rules:

  • Only one disk may be moved at a time.
  • Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod.
  • No disk may be placed on top of a smaller disk.

Ok this algorithm of Hanoi Tower :

if N = 1, so
N moved from  A to C directly
but if  N > 1, so
move  N-1 from A to B
then move  N from  A to C
move N-1 from  B to C
Note :
N = number of disk

Program Description

In making the program the Tower of Hanoi (Hanoi Towers), the author uses the program as entrepreter NetBeans 6.9.1 Java programs. The following steps for developing a program of Hanoi Tower.
1. Run NetBeans Program

2. Wait till program open

3. Make new project, with click File >> New Project, or press CTRL+SHIFT+N in keyboard. then choose Java Application in  Java Categories

4. click Next button for  Verifiaction Project Name, and at this example, the Project Name is hanoi; then click finish button for show work area

5. Then with click hanoi hierarchical , so will open Source Package, then click it hierarch for show up the basic/fundament Project namely hanoi , right click on this Menu then choose New >> JFrame Form

Verify the class name in the project made Hanoi. Then click Finish.

6. then  will appear GUI work area, and in the area, the author will make the components supporting materials, buttons, area fields, text fields, etc..

7. On menu palette on the left side of the work area, an additional component in the form of buttons, labels, text fields, etc can be made to support the Tower of Hanoi program created.
Drag some features found on Swing Controls palette menu on the left side of the java GUI work area. Here are the details of the use of features:

GUI Form Feature Name
Button Button
Area Text for Showing Text Label
Input Text Text Field
Process Output (will show result of program) Text Area
Show Loading Effect when program runs Progress Bar

Make program display like this :

8. Change the name of each feature is the GUI by right clicking on the relevant features, then click select Edit Text.

Do it this way to edit all posts in the work area, so the display views like this :

9. Furthermore, the variable name of each feature that has changed its name earlier, with the following details:

Form Display in GUI
Name of Features Name of GUI Name Variables
Buttonl 1 jButton1 Execute executeButton
Buttonl 2 jButton2 Reset resetButton
Button 3 jButton3 Exit exitButton
Text of Title jLabel1 Hanoi Tower titleLabel
Text of Number Disk for Input jLabel2 Enter Amount of Rings ringLabel
Text for Process jLabel3 Process processLabel
Total Numbers of  Movement’s Disks jLabel4 Total Movements Are totalLabel
Output for Process jTextArea1 processTextArea
Display Process like Loading Effect jProgress Bar1 jProgress Bar1
Text for input number of disks jText Field1 ringTextField

So the GUI display pictures of Tower of Hanoi program as follows:


9 Responses to "Make GUI Display (Swing) in Java"

[…] HomeTentangku Everyone Can Enjoy Opensource Don't Forbid Us to Know Everything « Make GUI Display (Swing) in Java […]

I simply needed to thank you so much again. I’m not certain the things I would have used without these information shared by you over such a subject. It seemed to be a real alarming scenario in my position, nevertheless considering the professional manner you resolved the issue took me to leap over delight. Now i am grateful for this support as well as wish you really know what a powerful job that you’re doing instructing the rest by way of a blog. Most likely you haven’t encountered all of us.

Earn up to $3500/month just by taking simple surveys online!

I tried one of those online survey sites about 4 months ago that
say all you have to do is spend a couple of minutes filling out
some surveys and you will be making hundreds a day….. YEAH RIGHT, I didn’t make anything.

I joined 7 of these stupid websites and I actually tried filling
out a couple of surveys on each site and they took forever then at
the end they wanted me to buy things or I couldn’t complete the

These are complete scams so be aware!!! I couldn’t believe they
were even allowed to sell such bogus products.

Then about 2 weeks ago I was watching the news and they had some
vice presidents and marketing managers of some major multi million
dollar companies talking about a site that they personally work
with to pay consumers for their opinion, A site that actually just
wants the “average Joe’s” honest opinion on products and services
and is willing to pay big money to get them.

>>>>> http://get-money-for-taking-surveys.info <<<<<<<>>>> http://get-money-for-taking-surveys.info <<<<<<<>>>> http://get-money-for-taking-surveys.info <<<<<<<<

“God is more concerned about our character than our comfort. His goal is not to pamper us physically but to perfect us spiritually.” – Paul W. Powell, original source unknown

great post, very informative. I wonder why the other experts of this sector do not notice this. You must continue your writing. I’m confident, you have a great readers’ base already!

Howdy! I know this is kinda off topic however I’d figured I’d ask. Would you be interested in exchanging links or maybe guest writing a blog article or vice-versa? My blog addresses a lot of the same topics as yours and I think we could greatly benefit from each other. If you might be interested feel free to shoot me an email. I look forward to hearing from you! Awesome blog by the way!

magnificent put up, very informative. I ponder why the opposite experts of this sector don’t realize this. You should continue your writing. I’m sure, you’ve a great readers’ base already!

I’m honored to get a call from my friend when he identified the important points shared in your site. Reading through your blog publication is a real brilliant experience. Thanks again for considering readers at all like me, and I want for you the best of success as a professional in this domain.

I was recommended this website by my cousin. I’m no longer positive whether or not this submit is written through him as nobody else realize such exact approximately my trouble. You’re incredible! Thank you!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s



%d bloggers like this: