Create Action Listeners with JButton – Java GUI/SWING Tutorial+HELP:
Jan.30, 2012 in
Windows 8 News

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
Video Rating: 4 / 5

January 30th, 2012 at 6:18 pm
@gustavoindustry You have to make sure that you separate the classes and methods right there should be? a closing? “}” before you create your ActionListener class at the bottom.
January 30th, 2012 at 7:06 pm
Super Awesome tutorial man? thanks a lot.
January 30th, 2012 at 7:35 pm
@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
January 30th, 2012 at 8:23 pm
Thanks for your explanation.? It’s a very good tutorials.
January 30th, 2012 at 8:53 pm
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.
January 30th, 2012 at 8:56 pm
nice? mr.
January 30th, 2012 at 9:40 pm
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
January 30th, 2012 at 10:33 pm
i get a error like yours at 5:08 can you show how fix??
January 30th, 2012 at 10:49 pm
Thank you so so? so much!!!
January 30th, 2012 at 11:30 pm
y is that panel so necessary..?? can’t v use? directly
January 31st, 2012 at 12:15 am
Thanks a lot for this. I would like to add things to the existing window… Juse add a couple of lines on the same screen. Adding a new JLabel? is not working… any recommendations?
January 31st, 2012 at 12:41 am
Acctually, all i need are image buttons.? I can do the other two things! Figured it it out!
January 31st, 2012 at 12:43 am
Also. can you do? image buttons?
January 31st, 2012 at 1:03 am
Oh and also, how can you make an image appear/ disappear with this?
replacing the label? Sorry, I? am such a begginner.
January 31st, 2012 at 1:33 am
OMG! THANKS! I am 11, and ive been using flash? for years. I am making one of my first java projects and your tutorial was just what I needed. But i need something for multiple buttons??
January 31st, 2012 at 1:35 am
hey MrJavaHelp, i? realy want to thank you for posting these video’s, and you helped me out quite a bit learning java. good going!
January 31st, 2012 at 1:47 am
Dude you are? awesome!!!
January 31st, 2012 at 2:15 am
@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.
January 31st, 2012 at 2:26 am
HI great work mate
Could you teach me how to put multiple? action listener for multiple buttons ??
January 31st, 2012 at 2:33 am
how to get button in other button in same? frame?
January 31st, 2012 at 2:41 am
waaa?