Hey everybody! Welcome to my new Java GUI tutorial!
What I expect you have:
1. netbeans IDE
2. a brain
3. some basic java knowledge
Note: netbeans makes very ugly code but the GUI is quite nice looking.
Creating a project
1. Create a new project by going to file > new project
2. make the project a java application by clicking on the java node and clicking 'java application'
3. right click on the project and click new >JFrame form
Finding your way around
you should now see something like this:
this may look frightening, but trust me, its not!
let me clear things up:
See! its not so bad!
now lets start making a little program!
go to the item menu and click on "Label"
drag that anywhere onto the dark box and place it. double click to edit text
now go back to the menu and add a 'Button'
now make another button!
[img] http://i.imgur.com/35mdtSC.png [/img]
now here comes the fun part, Action listeners!
but first, we need to add some text for the buttons to make appear!
make 2 Jlables and put them 1 under the other!
now right click on the top one and go to properties, then go to code and change variable-name to "hello"
[img] http://i.imgur.com/AQrNK54.png [/img]
now do the same for the bottom but make the name 'goodbye'
now change the text on the top one to "Hello!" and the text on the bottom one to "Goodbye!"
[img] http://i.imgur.com/yIQOpyt.png [/img]
next right click on each one and go to custom code, then add "Hello.setVisible(false)" and "Goodbye.setVisible(false)"
this will make both start invisible
now right click on the "Hello" button and click Events> action > actionperformed
this should take you to your source code
in this action performed method type the following "Goodbye.setVisible(false); Hello.setVisible(true);"
now go back to the design menu and make another actionperformed for the goodbye button.
now in the action performed method type "Hello.setVisible(false); Goodbye.setVisible(true);"
now just click the build and compile button
(hammer and brush)
let it compile and then click the run button!
(green arrow)
you have just made your first J-Frame! Congratulations!!
keep an eye out for more tutorials and program releases by me!