Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Create Action Listeners with JButton - Java GUI/SWING Tutorial+HELP:

Loading...

Sign in or sign up now!
64,508
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jul 22, 2009

This tutorial will teach you how to make action listeners, which allow actions to occur after a button (JButton) is clicked.

I will teach you how to make the action listener and to add Action listener to the button

Watch the last video for basic GUI and check out the next video which shows layout in Java

Category:

Howto & Style

Tags:

License:

Standard YouTube License

  • likes, 4 dislikes

Link to this comment:

Share to:

Top Comments

  • @AZCHIM @Olemassacre

    MULTIPLE ACTIONS FOR MULTIPLE BUTTONS:

    1: Transform your Components into Class Variables (after class definition w/ static).

    2: Use the "static inner class" MrJavaHelp gave you and insert the following code:

    if (e.getSource() == {insert your source component here}) // do shit and return

    else if (e.getSource() == {insert your source component here}) // do some more shit and return

    3: {insert your source component here}.addActionListener(new Action());

    Thumbs up if it helped.

  • i get a error like yours at 5:08 can you show how fix?

see all

All Comments (83)

Sign In or Sign Up now to post a comment!
  • Super Awesome tutorial man thanks a lot.

  • @MrTuhinBagh i thought the same thing at first but actually the JPanel is very necessary because with out it the button would cover the entire frame for some reason i think it help the objects in the frame be arranged or appear properly or something idk

  • Thanks for your explanation. It's a very good tutorials.

  • Should use a modal dialog instead of another frame. Also, realizing the container should be the last thing you do; adding components after the container has been realized may cause serious problems.

  • nice mr. :)

  • suddenly a new import comes at 2:33 "import sun.swing.text........." y is that for y i came like that? you did not not tell any thing about that

View all Comments »
Loading...

0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more