Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Buttons in Java

  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Buttons in Java

    Okay, so I need to make some buttons and connect them to methods. Unfortunately, I haven't the slightest idea how to begin. I've found various ways to make buttons, but I haven't figured out to make them call methods in another class. This is probably very simple, so I apologize.

    Thanks so much for your help!

  • #2
    Regular Coder
    Join Date
    May 2008
    Posts
    187
    Thanks
    7
    Thanked 7 Times in 7 Posts
    jButton.addActionListener(this); will add and action listener which will listen for clicks. If a click occurs on jButton it will search 'this' for the action handler to figure out what to do.

    Before you try doing UI, you should attempt to learn the basics of Java and OOP. Java's website java.sun.com has some good tutorials or you can checkout/buy a book on beginning java programming.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •