Added: 2 years ago
From: MrJavaHelp
Views: 64,434
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (77)

Sign In or Sign Up now to post a comment!
  • 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

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

  • Thank you so so so much!!! :)

  • y is that panel so necessary..?? can't v use directly

  • 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?

  • Acctually, all i need are image buttons. I can do the other two things! Figured it it out!

  • Also. can you do image buttons?

  • Oh and also, how can you make an image appear/ disappear with this?

    replacing the label? Sorry, I am such a begginner.

  • 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??

  • 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!

  • Dude you are awesome!!!

  • @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.

  • HI great work mate

    Could you teach me how to put multiple action listener for multiple buttons ??

  • Comment removed

  • how to get button in other button in same frame?

  • waaa

  • thank you, this was very helpful :)

  • Wow, very informative, good job.

  • How would I add a new label/button/etc. to an existing gui?

  • nevermind

  • i get errors bro doesnt work

  • thanks alot man youre helping me out good in my java programming class :D

  • Very nice and Thanku very much..........its really very helpful for beginners like me...

  • Is there a way to pass in another variable with the action

  • @youngday713 it should come with java

  • how do you get java swing???

  • @youngday713 import javax.swing.*;

  • Hey i get an error when i type button.AddActionListener(new Action());

    I typed exactly everything you did, i dunno whats wrong it says

    "cannot instantiate the type action"

    ive been doing java for a few weeks now so im not a total newbie i understand all the basic concepts so normally i can solve my own problems but im stuck here... please help me someone :s thanks

  • i just wondering can u make button to close the frame/window for example i had a button called cancel in the frame/window and when i click it the frame/window closes down plz help

  • hi dude nice tut. btw . if you don't mind can you send me a copy of this program? we need it for school project.:D thx.

  • verry good

  • You could also have used an Inner Class. That would have saved your time writing the Action method and then calling its instance.

    button.addActionListener(new ActionListener()

    { public void actionPerformed(ActionEvent ae) { // Fill here with the contents of actionPerformed  // method from the video. :-) }

    });

  • easy pc...:)

  • Umm, how to make the button on specific spot, and

    how to make something like: if (action == button clicked) {

    }

  • @ivandonat I'm wondering about the exact same! How to position objects and how to give more than one button different actions! Please tell if you get an answer!

  • @Olemassacre Got it, its button.reshape(something,somet­hing); i dont remember exactly because i didnt program java for a while

  • @ivandonat Oki, thanks! :D

  • "That's the algorithm for making our acion listener..."

    LMAO

  • thanks dude c:

  • Question No: 17 ( Marks: 1 ) What is the typical use of Hashtable?

    Question No: 18  ( Marks: 1 ) Why we use paintChildern( ) method?

    Question No: 19 ( Marks: 2 ) Write any two steps of painting strategy.

    Question No: 20 ( Marks: 3 ) Name three paint () methods which are used to paint Swing Component.

    Question No: 21 ( Marks: 5 ) Differentiate between Named and Anonymous Objects.

  • @MrUsman4040 Typical use of Hashtable is where fast-access ranks over sensible ordering. We use paint Childern method when they have watercolors. Named Objects have a name. Anonymous Objects do not exist, to say why would get me war-painted.

  • Hello MrJawaHelp, i absolutely love the GUI tutorials. Im working on a class project, although everything is Ok but one question.

    I am also using eclipse, but in your case eclipse is showing autocomplete options. In my case, it shows for basic java commands but the GUI related commands are not autofilled by eclipse. Am i missing something?

    Please help.

  • Netbeans is asking me to crate an interface for the action listener, how do i do that? and what should i code inside of it?

  • @tarunpai Declare an event handler class and specify that the class either implements an ActionListener interface or extends a class that implements an ActionListener interface -- which means that it has a method public void actionPerformed( ActionEvent e ){} and in that method you have to have a reference to the object you want to do someting with

  • can you do something like. when you click the button the last JFrame will close so that the new JFrame will only be visible?

  • yea just remove the JFrame.EXIT_ON_CLOSE in the first frame

  • u explain things so well

  • for those who have watched all the vids and cannot get ActionListeners to do useful work, what I did was give the class SomeClass extends ActionListener a reference to the class upon which it was supposed to act such as FirstClass.actionInvoker = new ActionInvoker(this); and have the ActionListener - SomeClass's ActionPerformed() method work the reference. This raises a circularity error risk but it is incumbent to sort those things as need be.

  • What should I do to create some more labels and buttons in the same frame instead of a new frame?

    Can some one tell me, have been stuck here for quite sometime now!

  • @panudeep

    JButton button1 = new JButton("Button 1");

    JButton button2 = new JButton("Button 2");

    JButton button3 = new JButton("Button 3");

    JButton button4 = new JButton("Button 4");

    panel.add(button1);

    panel.add(button2);

    panel.add(button3);

    panel.add(button4);

    :)

  • All people that are struggeling with that I noticed that Action class is inside swing2 class. Thank for tut very nice

  • Hmm if anyone wants to be a concerned programmer.. Dont import .* actually find the classes you need. Using .* imports the whole package.

  • i want to create a bottom which calls a new forms contains database with netbeans .

    please help me urgent.

  • hi just want to ask wat if i have 2 button how do i type inorder when i click on button one my particular for button1 will appear and same for button 2?

  • okay, only other question i have, after static class when you name your action, mine gets a syntax error. in the video his did too, but when he puts a close bracket after the pannel.add it fixes it. In my program I have multiple buttons that I eventually want to put sound into when I click them. But I get errors on every other button when I add that close bracket. please help.

  • Anyone know how to add an actionlistener to play a soud file? please message me.

  • well explained, but you still didn't explain how to use layouts which was suppose to be this video.

  • The same question as the one below:

    Do you need to add different action Listeners 4 every object you create?

    How about radioButtons, sliders etc?

    But thank you for your videos... very helpful.

  • Yes, it can become tedious, but you have add an action listener everytime you want to make a button do something. Also, for radioButtons and sliders its a bit different in terms of the actionListeners, but you still have to add it for every single one.

  • do u need to add......:

    static class action1 implements ActionListener{

    public void actionPerformed (ActionEvent e){ .....to every individual button ????

  • You make it so easier than my lectures!!! haha

  • thank you very much MrJavaHelp

  • I stumbled onto this just-in-time. very straight forward! ... I will have to watch a few more then possibly recommend.

  • U r my Hero man...GOD BLESS YOU

  • Ugh, you really should learn what an algorithm is before you use it in a video. >____>

    The beginning of a class declaration is NOT an algorithm.

  • I am using NetBeans also, and was wondering if you could tell me why NetBeans creates a Main.java as the main method starting point? Also, I was able to follow your code rather easily, however with NetBeans, I got the same message, "static is not allowed here". Can you help? BTW, I enjoyed your video. Thanks.

  • Im a biggner in java and its so easy btw i normally program in visual basic and c# i know the full visual basic lanuage but i also wannna program for linux so im going to learn java as well

  • when i write the second class (static class action implements ActionListener), netbeans says "static is not allowed here". I don't know how to fix this, i wrote the whole code like you.

  • Easy stuff, but good video though!!.

    Just try NOT to say (so) so much in ur next video.

  • thank you

  • Be cool if you could add previous / next lesson at the end of the tutorial as well. :)

    thanks. nice tut.

  • THere you go,I added that :)

  • do you know how i make a message box in java?

  • This is easy stuff, but good tutorial though.

    I am looking forward to your next video.

    I really don't know how to position objects in your frame.

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