Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Java basic GUI with NetBeans

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Location
    Fort Worth, Texas
    Posts
    13
    My Mood
    Fine
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Java basic GUI with NetBeans

    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!

  2. The Following User Says Thank You to Earthly Minds For This Useful Post:

    Ludus.H1 (February 7th, 2016)


Similar Threads

  1. Netbeans GUI help
    By kprofgold in forum AWT / Java Swing
    Replies: 1
    Last Post: February 26th, 2012, 07:02
  2. JAVA netbeans - GUI how to get my scroll bar to work?!
    By camel in forum AWT / Java Swing
    Replies: 5
    Last Post: April 18th, 2011, 07:15
  3. NetBeans-style GUI
    By susieferrari in forum Java Theory & Questions
    Replies: 7
    Last Post: March 31st, 2011, 09:40